|
-
Oct 4th, 2009, 10:37 PM
#1
Thread Starter
Member
[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.
-
Oct 4th, 2009, 10:55 PM
#2
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
Last edited by seenu_1st; Oct 5th, 2009 at 12:04 AM.
-
Oct 5th, 2009, 06:32 PM
#3
Thread Starter
Member
Re: MsFlexGrid value placed in textbox ?
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.
-
Oct 5th, 2009, 09:41 PM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|