Results 1 to 7 of 7

Thread: [RESOLVED] Show related data in textboxes from MSHFlexgrid on clicking?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Posts
    788

    Resolved [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.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Posts
    788

    Re: Show related data in textboxes from MSHFlexgrid on clicking?

    Quote Originally Posted by si_the_geek View Post
    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,
    Last edited by VBLearner6; Feb 3rd, 2010 at 02:24 AM.

  4. #4
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    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
    Last edited by Spoo; Feb 1st, 2010 at 12:59 PM.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Posts
    788

    Re: Show related data in textboxes from MSHFlexgrid on clicking?

    Quote Originally Posted by Spoo View Post
    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?

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    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

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2007
    Posts
    788

    Re: Show related data in textboxes from MSHFlexgrid on clicking?

    Quote Originally Posted by Spoo View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width