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

How to:Combo control in Grid contains table field value

Status
Not open for further replies.

Eliott

Programmer
Nov 8, 2009
91
BA
I'm familiar with the way how to put combo control into Grid's column but I don't know how to achieve that this combo show as its value the values from tables field in which column is situated. For example, in some able there is field how much times customers replaced some articles: Never, 1st time,2nd time,3rd time,more than 3 times. I created Combo with these values but I'm unable to "tell to the Grid" to change Combo's value to proper value based on field value. I tried to put fields with complaints quantity as column in Grid and to read it and then change Combo's state but doesn't work.
Is there some special moment where I need to put some IF checking but on what basis?
Code:
*combo in grid u 6. column
.Column6.header1.caption="No. of returns"
 .Column6.ControlSource = "complains.pt_howmany"
 .Column6.AddObject("othControl","combobox")
 .Column6.CurrentControl = "othControl"
 .Column6.Width=70
 .Column6.othControl.AddItem("1nd time")
 .Column6.othControl.AddItem("2nd time")
 .Column6.othControl.AddItem("3rd time")
 .Column6.othControl.AddItem("more than 3 times")
 .Column6.othControl.AddItem("Never")
 .Column6.othControl.Listindex=1
 .Column6.Sparse = .F.
 .column6.visible=.t.
... *inside programmatically designed grid set up Combo state:
do case
case ALLTRIM(thisform.grid1.column5.text1.value)>3
 thisform.grid1.Column6.othControl.Listindex=3
...
*end of design grid
Thank you

There is no good nor evil, just decisions and consequences.
 
The .value property of any control autofills via .controlsource, and that's also true for the combobox.

I never used a combo filled by additem in a grid. I'd say as the controlsource sets the combo.value and not the listindex, the seond necessary thing would be a secondary corresponding value in a second combobox column, and then (3rd) the boundcolumn property should be set to that column, to 2.

Bye, Olaf.
 
Eliot,

I think the problem is that there is a clash between the values you are placing in the combo ("1st Time", etc) and the values provided by the ControlSource.

It might be better not to set the ControlSource. Then, in the combo's LostFocus, explicitly store the required value in complains.pt_howmany:

REPLACE complains.pt_howmany WITH ICASE( ;
THIS.Value = 4, 3, ;
THIS.Value = 5, 0, THIS.Value)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top