Results 1 to 4 of 4

Thread: Pass row(s) of Flexgrid to textboxes - How?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    101

    Question Pass row(s) of Flexgrid to textboxes - How?

    I have a Flexgrid which is filled by a Recordset (the contents of which are gained through a SQL query).

    The recordset may contain around eg. 10 records, but what I want, is that when a user clicks on one row, the contents of each cell in that row, are displayed in appropriate textboxes.

    Example:
    When the Flexgrid is populated, it will have (as an example) 5 cells per row...

    These cells are named:
    CustID, CustSurname, CustForename, CustPhone, CustAddress

    When the user clicks on the the 3rd row of the Flexgrid (which is actually the 3rd record in the recordset), I would like each field to be displayed in its appropriate textbox:

    txtCustID, txtCustSurname, txtCustForename, txtCustPhone, txtCustAddress


    I have thought of 2 ways to do this:
    1. Pass each cell value directly to each textbox
    2. Pass the row to a recordset, then get populate the textboxes by using the recordset values...


    A small problem with both ideas:
    What if the user should click more than 1 row, eg. they click 3 rows?
    How would I then do this?

    Is it possible I could then send the 3 rows (3 records) to a new recordset, and then send each record in turn to the textboxes (and use back/forward buttons to scroll)?


    Can anyone please help?

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2004
    Posts
    101
    Nobody know how ?

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    If your textboxes were a control array it would be very simple.

    VB Code:
    1. Dim intIndex As Integer
    2.    
    3.     For intIndex = 0 To MSFlexGrid1.Cols - 1
    4.         txtMyControlArray(intIndex) = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, intIndex)
    5.     Next

    Even if it's not you can still do it pretty easily.

    VB Code:
    1. Dim intIndex As Integer
    2.    
    3.     For intIndex = 0 To MSFlexGrid1.Cols - 1
    4.         Select Case intIndex
    5.              Case 0
    6.                 txtCustID = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, intIndex)
    7.              Case 1
    8.                 txtCustSurname = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, intIndex)
    9.             ' etc
    10.         End Select
    Next

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Do you need this multiple-row-click functionality? What I mean to ask is, if it's not a necessary feature, then you can remove it by setting the SelectionMode property of the grid to flexSelectionByRow.

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