Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo Box : Not showing values unless focus is set to it
Message
From
01/12/1998 15:05:05
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00145892
Message ID:
00162923
Views:
26
>>Try
>>This.Value=This.List(1) in the init of each combo box - works for me
>>Ashley
>>
>
>Hi Ashley,
>This doesnt accomplish what is needed. Sylvia was wanting a combo box to show the item in the list that corresponds to the value of the Value property of the combo box, not the the first item in the list.

Rick (and others!:) -

I'll tell you what I got to work, but I'll be damned if I know why. Perhaps you or someone else can explain what seems like unusual behavior to me. First of all, I have my comboboxes on a page frame (as I believe Jayesh did). Secondly, I have some method code in the Activate of the first page which does a refresh (this comes into play in a minute). Third, I was trying to get some default value to display for the combox (in add mode only), so Ashley was right about that.

Here are the settings for my combo:

BoundColumn: 2
BoundTo: T
ControlSource: Cfenhance.en_category (type: integer)
RowSource: CfCatego.ca_name, ca_id
RowSourceType: 6 - Fields

The ca_name is what I wanted displayed in the combo and the ca_id is the integer I want stored by the control source. So far, so good

What finally worked for me was putting the following code in the m_action method of my Add button:
DoDefault()
With ThisForm.pageframe1.pgdataentry
.cboen_category.Value = .cboen_category.List(1,2)
EndWith
This.m_setfocus()

This is a variation of Ashley's recommendation. Putting This.Value=This.List(1) in the Init didn't work, because the Refresh I mentioned above seemed to 'wipe out' the value. I put some wait windows before and after the suspect, and saw that there initially was a value, then there wasn't after the refresh. Sooo... I decided to put that code where I really wanted it: in my add button. But it didn't work until I specified List as List(1,2). It didn't work when I changed bound column to 1 and changed the code above to List(1,1) or when I put This.Value=This.List(1,2) in the init of the combo, i.e. I got the same blank combo box again. This is what really baffles me: Why do you have to set the value to the (in my case integer) value you're storing for the control source in order to see the value I really want (namely the name:) in the combo box?? Secondly, why would a refresh of a page obliderate the value in the combobox?

Sorry for this really long explanation, but I'd really like to understand what's going on here.

Thanks,

Sylvia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform