[RESOLVED] Show related data in textboxes from MSHFlexgrid on clicking?
Dear Friends,
I am using VB6 with MS Access as backend database. The recordset is bounded to database through MSHFlexGrid. (Set MSHFlexGrid1.DataSource = rs)
I have 4 columns in MSHFlexGrid & 4 Textboxes on form.
Now, when I move through the records in MSHFlexGrid the exact data in the cells should appear in the related textboxes.
How to get this job done?
Thanks in advance.
Re: Show related data in textboxes from MSHFlexgrid on clicking?
Simply use .TextMatrix to read the values, eg:
Code:
Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row,1)
Re: Show related data in textboxes from MSHFlexgrid on clicking?
Quote:
Originally Posted by
si_the_geek
Simply use .TextMatrix to read the values, eg:
Code:
Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row,1)
Thanks a million for this help. I was looking for this code since long time. I have another question but related to the same subject. How can I get the same thing instead of clicking on MSHFlexGrid1 every time, just by moving through MSHFlexgrids using up & down arrow keys?
Regards,
Re: Show related data in textboxes from MSHFlexgrid on clicking?
VBLearner6
Your question is somewhat ambiguous.
Do you mean that you would like to "scroll" the FlexGrid
by using the UP and DN arrow keys on the keyboard?
Or do you mean something else?
If you mean the former (highlighted in blue), then you could
add a KeyPress event, and trap for the UP and DN key.
You will need a counter that represents TopRow, and another
for the current row. The KeyPress would essentially increment/decrement
these counters by 1 with each key press. Its a little more complicated
than that, but that generally describes things.
Does that help get you started?
Spoo
Re: Show related data in textboxes from MSHFlexgrid on clicking?
Quote:
Originally Posted by
Spoo
VBLearner6
Your question is somewhat ambiguous.
Do you mean that you would like to "scroll" the FlexGrid
by using the UP and DN arrow keys on the keyboard?
Spoo
Yes. Suppose I have clicked on first row and first cell of my MSHFlexgrid1, now I would like to scroll down to select each cell in MSHFlexgrid1 through using Up & Down arrow keys on my keyboard instead of always clicking on each cell to select. How it can be done?
Re: Show related data in textboxes from MSHFlexgrid on clicking?
VBLearner6
Well, one possibility is to use the KeyDown event.
You can create a "stub" in design mode by double clicking
your FG and then selecting KeyDown from the upper right
drop down list. It would look something like this.
Code:
Private Sub MSHFlexgrid1_KeyDown(KeyCode As Integer, Shift as Integer)
End Sub
KeyCode for
dn arrow key is 40,
up arrow key is 38,
lf arrow key is 37,
rt arrow key is 39.
Does that get you started?
Spoo
Re: Show related data in textboxes from MSHFlexgrid on clicking?
Quote:
Originally Posted by
Spoo
VBLearner6
Well, one possibility is to use the KeyDown event.
You can create a "stub" in design mode by double clicking
your FG and then selecting KeyDown from the upper right
drop down list. It would look something like this.
Code:
Private Sub MSHFlexgrid1_KeyDown(KeyCode As Integer, Shift as Integer)
End Sub
KeyCode for
dn arrow key is 40,
up arrow key is 38,
lf arrow key is 37,
rt arrow key is 39.
Does that get you started?
Spoo
Thanks a lot to both of you (Mr. si_the_geek & Mr. Spoo) for your kind help.