Results 1 to 11 of 11

Thread: Click a flexgrid row, get value of cell in column 0 ?

  1. #1

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818

    Question Click a flexgrid row, get value of cell in column 0 ?

    I have a flexgrid with 6 columns and various amounts of rows.

    If I click anywhere in the flexgrid I want to move the value of the cell in column 0 for that row in to a textbox.

    Is there a quick way to do this ?

    Last time I trapped values in cells I had to declare 2 variables called X and Y and plot where I was, but I'm not sure if this is the best way to go.

    Any takers ?

  2. #2
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    this help?

    VB Code:
    1. Private Sub MSFlexGrid1_Click()
    2.     MSFlexGrid1.Col = 0
    3.     MsgBox MSFlexGrid1.Text
    4. End Sub

    dont like the flexgrid, funny to work with
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  3. #3
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Try this:

    Text1.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0)

  4. #4

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Cheers Guys.

    Amazingly simple really, I just need to invest in a brain first

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    nah, i dont like the flexgrid, too brain-needy
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  6. #6

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    I'll admit they can be fiddly to work with.

    I presume you use DataGrids instead then do you ?

  7. #7
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    i've just started fiddling with my first ListView control, very useful
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  8. #8

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    I like the way you can click a listview header and have it sort on that column. Very handy.

  9. #9
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    ive just posted a problem with that
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  10. #10
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641
    I like the way you can click a listview header and have it sort on that column. Very handy.
    That can be done with a flex grid too, just add the following code

    VB Code:
    1. Option Explicit
    2.  
    3. ' variables for enabling column sort
    4. Private m_iSortCol As Integer
    5. Private m_iSortType As Integer
    6.  
    7. Private Sub MSHFlexGrid1_DblClick()
    8. '-------------------------------------------------------------------------------------------
    9. ' code in grid's DblClick event enables column sorting
    10. '-------------------------------------------------------------------------------------------
    11.  
    12.     Dim i As Integer
    13.  
    14.     ' sort only when a fixed row is clicked
    15.     If MSHFlexGrid1.MouseRow >= MSHFlexGrid1.FixedRows Then Exit Sub
    16.  
    17.     i = m_iSortCol                  ' save old column
    18.     m_iSortCol = MSHFlexGrid1.Col   ' set new column
    19.  
    20.     ' increment sort type
    21.     If i <> m_iSortCol Then
    22.         ' if clicking on a new column, start with ascending sort
    23.         m_iSortType = 1
    24.     Else
    25.         ' if clicking on the same column, toggle between ascending and descending sort
    26.         m_iSortType = m_iSortType + 1
    27.     If m_iSortType = 3 Then m_iSortType = 1
    28.     End If
    29.  
    30.     DoColumnSort
    31.  
    32. End Sub
    33.  
    34. Sub DoColumnSort()
    35. '-------------------------------------------------------------------------------------------
    36. ' does Exchange-type sort on column m_iSortCol
    37. '-------------------------------------------------------------------------------------------
    38.  
    39.     With MSHFlexGrid1
    40.         .Redraw = False
    41.         .Row = 1
    42.         .RowSel = .Rows - 1
    43.         .Col = m_iSortCol
    44.         .Sort = m_iSortType
    45.         .Redraw = True
    46.     End With
    47.  
    48. End Sub
    Martin J Wallace (Slaine)

  11. #11

    Thread Starter
    Frenzied Member TheBionicOrange's Avatar
    Join Date
    Apr 2001
    Location
    Cardiff, UK
    Posts
    1,818
    Cheers Slaine. I might find a use for that

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