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?
john_priceAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TimCotteeConnect With a Mentor Commented:
Didn't read the second half of the question. Here is a way to test whether the user clicks a row selector:

Private Sub DBGrid1_SelChange(Cancel As Integer)
    If DBGrid1.SelBookmarks.Count = 1 Then
        MsgBox ("Row Selector Clicked")
        DBGrid1.SelBookmarks.Remove 0
    End If
End Sub
0
 
john_priceAuthor Commented:
Edited text of question.
0
 
adityauCommented:
I don't think it can be done. Why don't you use a list vies control?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TimCotteeCommented:
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.
0
 
john_priceAuthor Commented:
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.
0
 
john_priceAuthor Commented:
Thanks again guys.
0
All Courses

From novice to tech pro — start learning today.