Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combobox in grid not displaying data when selected 2

Status
Not open for further replies.

Dan777

Programmer
Jul 22, 2000
34
US
I have a typical combobbox in a typical grid to allow users to enter typical data. The problem is that when the combobox in the grid has focus, the displayvalue is not showing. When the form is loaded, the data displays fine in each combo in each row in the grid, but as soon as the grid receives focus, the combobox of the active row goes blank. The other rows display their data properly.

With the debugger open in a separate window, and watches set on the value and displayvalue of the combo, I can see the displayvalue switching between a legitimate value and 'blank' value when alt-tabbing between the app and debugger, giving focus to the combo in the grid. And of course, when taking the combo as is and putting it right on the form instead of in the grid, it works fine.

To isolate the problem I put in a little code in the InteractiveChange event of the combobox to set focus to a different control on the form. Unfortunately, that works just as expected; as soon as a value in the combo is selected, focus goes to a different control, and the value IS displayed.

The grid has 1 column, is populated from a cursor, with type of Alias. The combo has a rowsource type of Fields, with the rowsource being the displayed value field (char) and the data value field (int).

Any ideas? Thanks much!
Dan
 
The grid has 1 column,
[\quote]
And the reason for having a grid with 1 column and a combobox in that 1 field is ??????
or
Did I read it wrong.

David W. Grewe Dave
 
It's a 1 to many form. The "1" is a therapy group. The many is the therapist(s) that facilitated each group. There's a couple hundred therapists that can facilitate each therapy group, and each group can have 1 or more therapists facilitating it. The combo in the grid is to allow end users to specify the therapists that facilitated each group. Of course there are other ways to implement this solution, such as a multi select list box, or a mover, but this is the one that is wanted by the people who pay the bills.
 
How is Sparse set for that column? Does changing to the other setting cure the problem?

Tamar
 
Asumming that the rowsource of the combobox is coming from table A and the control source of the combobox is Table B;
Check the field widths of the Table B field. It should be the same as Table A. If it is less and the choice selected is larger, it will not display.

I am not clear on:
"...displayed value field (char) and the data value field (int)."
If you are combining 2 fields, increase the size in Table B to the largest possible combination of these 2 fields.
 
Yeah, I've been playing with that infamous sparse prop as well. When set to false it behaves as described above. When set to true, it further enhances the head ache. When set to true, when the combo has focus, the proper display value is visible (Yaaa!). BUT, when the combo loses focus, the integer value (the combos value prop - the cursor's record key) appears. It's like it should have sparse set to .T. when it has focus, and .F. when it loses focus. Of course I could put some code in to make that happen, but is that the only work around?

After writing that last sentence, putting in code to change the value of the column's sparse when getting and losing focus, and low and behold it works... at least things appear as they should. It just doesn't feel right to have to change the sparse value like that, ya know.

Thanks Tamar.
 
No, changing Sparse on the fly feels wrong.

If you're storing a different value than you're displaying, make sure you have the value you want shown in the first column.

Tamar
 
What would happen if you put a property in the form type array
Then select the contents from the file into the array in the init of the form

Make the RowSourceType of the Combo = 5 array
Style = Dropdown list
Place the combo on the grid

And requery the combo when you change the values
 
I bet the controlsource of the combo within the grid is an integer primary key, and the combo is bound to an integer foreign key. Then you have that problem. First try to only set Format="R", that may already resolve it. Otherwise SET DECIMALS TO 0 and SET FIXED ON.

See this discussion in the newsgroups I had with Igor Koroljov:
Bye, Olaf.
 
Thanks for the responses guys.

Olaf, you ROCK! You and Igor were right on the money!!!

The controlsource of the combo is in fact an integer primary key, and the combo is in fact bound to an integer foreign key. When I set FIXED to ON it worked, the display value was visible when the combo had focus. The decimals are still set to the default, 2, and it still worked, but I'm not even gonna try to figure that one out. From the sound of your discussion it seems like this is in fact a bug that's been around for years, that even microsoft doesn't want to tackle!

THanks again!
 
Thanks Dan,

I also like the solution to set a relation and have the combobox boundto=.f. and no controlsource. The problem is how the combobox figures out the record matching the value set by the controlsource in the boundcolumn. A symptom of the problem is, that although you have set the controlsource and boundcolumn as an integer field, the type of the value is "C". There is some string conversion and comparison behind the scenes, and that depends on SET FIXED and/or SET DECIMALS.

Format="R" (with an empty inputmask) can solve another problem, when the displayvalue only shows a left portion of the value it should display.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top