|
-
May 2nd, 2002, 09:24 AM
#1
Thread Starter
Frenzied Member
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 ?
-
May 2nd, 2002, 09:37 AM
#2
Bouncy Member
this help?
VB Code:
Private Sub MSFlexGrid1_Click()
MSFlexGrid1.Col = 0
MsgBox MSFlexGrid1.Text
End Sub
dont like the flexgrid, funny to work with
-
May 2nd, 2002, 09:40 AM
#3
Hyperactive Member
Try this:
Text1.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0)
-
May 2nd, 2002, 09:44 AM
#4
Thread Starter
Frenzied Member
Cheers Guys.
Amazingly simple really, I just need to invest in a brain first
-
May 2nd, 2002, 09:45 AM
#5
Bouncy Member
nah, i dont like the flexgrid, too brain-needy
-
May 2nd, 2002, 09:48 AM
#6
Thread Starter
Frenzied Member
I'll admit they can be fiddly to work with.
I presume you use DataGrids instead then do you ?
-
May 2nd, 2002, 09:55 AM
#7
Bouncy Member
i've just started fiddling with my first ListView control, very useful
-
May 2nd, 2002, 10:05 AM
#8
Thread Starter
Frenzied Member
I like the way you can click a listview header and have it sort on that column. Very handy.
-
May 2nd, 2002, 10:14 AM
#9
Bouncy Member
ive just posted a problem with that
-
May 2nd, 2002, 10:41 AM
#10
Fanatic Member
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:
Option Explicit
' variables for enabling column sort
Private m_iSortCol As Integer
Private m_iSortType As Integer
Private Sub MSHFlexGrid1_DblClick()
'-------------------------------------------------------------------------------------------
' code in grid's DblClick event enables column sorting
'-------------------------------------------------------------------------------------------
Dim i As Integer
' sort only when a fixed row is clicked
If MSHFlexGrid1.MouseRow >= MSHFlexGrid1.FixedRows Then Exit Sub
i = m_iSortCol ' save old column
m_iSortCol = MSHFlexGrid1.Col ' set new column
' increment sort type
If i <> m_iSortCol Then
' if clicking on a new column, start with ascending sort
m_iSortType = 1
Else
' if clicking on the same column, toggle between ascending and descending sort
m_iSortType = m_iSortType + 1
If m_iSortType = 3 Then m_iSortType = 1
End If
DoColumnSort
End Sub
Sub DoColumnSort()
'-------------------------------------------------------------------------------------------
' does Exchange-type sort on column m_iSortCol
'-------------------------------------------------------------------------------------------
With MSHFlexGrid1
.Redraw = False
.Row = 1
.RowSel = .Rows - 1
.Col = m_iSortCol
.Sort = m_iSortType
.Redraw = True
End With
End Sub
Martin J Wallace (Slaine)
-
May 3rd, 2002, 04:14 AM
#11
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|