john_price
asked on
dbGrid HeadClick and row click
I'm coding a dbGrid (VB6, SP3) to do a sort based upon the column field when the user clicks on the column header. Is there any way I can supress the column highlighting? It is distracting. In stead, is there any way of adding an icon to the header to indicate it is the sort column?
Also, is there any way to detect that the user has clicked a row selector button?
Also, is there any way to detect that the user has clicked a row selector button?
I don't think it can be done. Why don't you use a list vies control?
adityau, whilst using a listview may be suitable in some circumstances, I would guess that it would require significant changes to john_price's code especially seeing as you cannot use a listview to edit the contents of the cells in place as you can with the DBGrid.
I would suggest that you use the following:
Private Sub DBGrid1_HeadClick(ByVal ColIndex As Integer)
DBGrid1.ClearSelCols
End Sub
It doesn't completely remove the highlighting, it still occurs for a fraction of a second, but then disappears.
I would suggest that you use the following:
Private Sub DBGrid1_HeadClick(ByVal ColIndex As Integer)
DBGrid1.ClearSelCols
End Sub
It doesn't completely remove the highlighting, it still occurs for a fraction of a second, but then disappears.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
adityau, I like the listview; think it's classy, but agree with TimCottee about the required shift in existing code. I'm not using the grid for edits, preferring to display a dialog instead, since the row is built from several tables, however, TimCottee's change did the trick. The brief highlighting that is left is actually positive, since it provides feed back that a column has been clicked. It (usually) disappears as soon as the mouse up occurs. I say "usually", because for some reason, the headclick occassionally does not happen, particularly when the user is moving the mouse quickly between columns. In that event, the column is not sorted and remains highlighted. This also provides feedback, prompting the user to click it again.
Thanks to both of you. adityau, I thank you for the suggestion, but have to give the points to TimCottee for this one.
Thanks to both of you. adityau, I thank you for the suggestion, but have to give the points to TimCottee for this one.
ASKER
Thanks again guys.
ASKER