[RESOLVED] MsFlexGrid value placed in textbox ?
Can anyone tell me how to place a value from an MsFlexGrid location into a Textbox upon program startup.
I have an Access database file that fills the flexgrid with data.
I then want the program to randomly pick a Row and Col from the flexgrid to display in the textbox at startup.
Thanx,
Bob K.
Re: MsFlexGrid value placed in textbox ?
u can get the cell value to the textbox like this
Code:
Text1.Text = MSFlexGrid1.Clip
edit: u can try something like this
Code:
Text1.Text = MSFlexGrid1.TextMatrix(1, 1)
u can select randomly the row,col values by random function, hope u got it, if not u can feel free to ask
Re: MsFlexGrid value placed in textbox ?
Quote:
edit: u can try something like this
Code:
Text1.Text = MSFlexGrid1.TextMatrix(1, 1)
u can select randomly the row,col values by random function, hope u got it, if not u can feel free to ask
seenu_1st,
I tested this example you gave by placing different values for the row/col, like
Code:
Text1.Text = MSFlexGrid1.TextMatrix(10,1)
and
Code:
Text1.Text = MSFlexGrid1.TextMatrix(3,2)
worked fine except that the cell that was placed in the text box replaced the cell value at (1,1) each time.
Re: MsFlexGrid value placed in textbox ?
try this code, hope this is wat u want, add a msflexgrid, textbox and command button
Code:
Dim i, j As Integer
Private Sub Command1_Click()
Randomize
i = Int(Rnd * 5) 'random number between 0 to 4
j = Int(Rnd * 5) 'random number between 0 to 4
Text1.Text = MSFlexGrid1.TextMatrix(i, j)
End Sub
Private Sub Form_Load()
MSFlexGrid1.FixedCols = 0
MSFlexGrid1.FixedRows = 0
MSFlexGrid1.Cols = 5
MSFlexGrid1.Rows = 5
For i = 0 To 4
For j = 0 To 4
MSFlexGrid1.TextMatrix(i, j) = i & "," & j
Next
Next
End Sub