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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with combox inside container in grid

Status
Not open for further replies.

WIREMESH

Programmer
Mar 15, 2004
109
0
0
US
I have a container with a few textboxes and a combo box that is used as a column in a grid.
The textboxes are bound to columns in my updateable cursor. As I move from row to row I can enter information into the textboxes with no problem. However, If I use a cursor or array as the controlsource in my combo box whenever I change the value of the combobox for a row, all rows in the grid are updated with the same value. I believe the issue is all of the containers combobox are bound to a single source. So when I change the value all of the rows show the same value in to combobox.

How can I work around this? The dropdown box is used to enter a person that performed work for that record.
 
 http://files.engineering.com/getfile.aspx?folder=ff691ac7-3d3d-4f0c-ae35-6ee1c480f874&file=grid_issue.png
I found a work around. I create another textbox next to the combobox. I then change the width of the combobox to onbly show the selection arrow. When the user selects a value in the valid clause I then set the value of the bound textbox to the value in the dropdown. This in effect simulates a dropdown control. Since the width of the combobox is so narrow, the user only sees the arrow on all of the records. Since the textbox is readonly, bound to a textbox in my cursor I now have the value I want.
 
I wonder if this is related to the Sparse setting for the grid column. I'm not sure how that interacts when you have a container in the column, but make sure Sparse is set to .T.

Tamar
 
If the combobox should have a per row value it has to be bound to some key field in the grid table/cursor/alias, because only being bound to some field of the grid alias you get a per row difference. That's what the grid is all about. Repeatedly showing an unbound combobox lets every grid row show the same, yes.

Example: Your grid displays services, your combobox displays techs assigned to a service, each service row has a techid, then the combobox.controlsource has to be services.techid and it's rowsource is techs.name, id, boundcolumn is 2 and so you have a two way binding of services.techid and techs.id: 1. The services.techid used as controlsource of the combobox picks the tech assigned to the service and 2. picking another tech you change the services.techid.

That's the essential mode of a combobox working for picking a foreign key. Contorlsource is parenttable.foreignkey and rowsource is childtable.displaydata, id, as you don't want to show the id, but need it to bind the foreignkey as controlsource. Obviously to not display the second column in the combobox, set columnwidths to 100,0 (second column with 0 width is the id you don't want displayed).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top