|
Question : Accesing value of a grid cell from another cell
|
|
In Visual FoxPro 5.0a,
Given a cell with 3 collumns:
If I program some event, say the click event to do someting based on the value of another cell, for instance:
Say the click event for Column1 contains the following code:
IF THISFORM.Grid1.Column3.TEXT.VALUE = .T. MessageBox("OK", 48, "Message) ENDIF
Assume a grid with only 2 rows, the first one has .F. on the first row and .T. on the second.
When you run the cell, the first time you click on a cell on column 1 it works as expected, after this, clicking on any other row causes the code to behave as if it were reading the value of column3 at the first clicked row.
This behaviour repeats unless you click the cell on column3 for the new row first, and then on the cell in column1, in which case it works as expected.
Attemting to call SetFocus or Activate cell to simulate the click on the column3 cell does not work either.
Using other events such as gotfocus or when does not solve the problem either.
The question then is: How can I read the data from a column other the the active column in a cell (on the same row) in such a way that I can obtain the correct value each time I change rows?
|
|
Answer : Accesing value of a grid cell from another cell
|
|
Okay... I think I got it.
Try this code in the AfterRowColChange event of the grid:
Note: This code assumes that the value in the TextBox of column3 is of a boolean type.
local lbValue
lbValue = ThisForm.Grid1.Column3.Text1.ControlSource
if &lbValue
wait window "The result was True"
endif
if ! &lbValue wait window "The result was False" endif
Kinda strange though. I got the same behavior that you descibed. I found no reference in the KB about it either. Oh well. The above code worked.
Donald
|
|
|
|