Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexgrid: Column Select/Deselect 1

Status
Not open for further replies.

Rougy

Programmer
Oct 15, 2001
249
US
Hi,

For instance, if somebody clicks Item #2 on the form, then Column #2 is highlighted, then when they click Item #5, Col #2 is deselected and Col #5 is selected.

Been looking through the FAQs and can't seem to find it.

Thanks.

-----
The death of dogma is the birth of reason.
 
You can try something like this in the click event. My grid has one fixed row (column headings) and no fixed columns. If yours is different you may need to make adjustments.

Private Sub MSFlexGrid1_Click()
'// change the back and fore colour of a column.
'// Reset all columns.
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 0
MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1
MSFlexGrid1.ColSel = MSFlexGrid1.Cols - 1
MSFlexGrid1.FillStyle = flexFillRepeat
MSFlexGrid1.CellForeColor = MSFlexGrid1.ForeColor
MSFlexGrid1.CellBackColor = MSFlexGrid1.BackColor
'// Highlight selected column.
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = MSFlexGrid1.MouseCol
MSFlexGrid1.RowSel = MSFlexGrid1.Rows - 1
MSFlexGrid1.ColSel = MSFlexGrid1.Col
MSFlexGrid1.FillStyle = flexFillRepeat
MSFlexGrid1.CellForeColor = vbButtonText
MSFlexGrid1.CellBackColor = vbCyan
If MSFlexGrid1.MouseRow = 0 Then
MSFlexGrid1.Row = 1
Else
MSFlexGrid1.Row = MSFlexGrid1.MouseRow
End If
End Sub


Thanks and Good Luck!

zemp
 
Thanks. I think I can work with that. I have a fixed header and left column, but I'll work it out.

Adios.

-----
The death of dogma is the birth of reason.
 
I don't know why I was thinking so complicated first. You can also set the .SelectionMode property to '2 - By Column' and will highlight the selected column.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top