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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Grid HeadClick Event

Status
Not open for further replies.

demoman

Programmer
Oct 24, 2001
242
US
I use the HeadClick event to sort data by the selected column. Works great. But, the Click event also fires. That is not so great. Also, click fires 1st, so I cannot add code to tell Click to relax if it was actually a headclick event. Right now, I am stuck with using dblClick which I prefer NOT to do. Anyone know a way to work around this?

Thanks
Steve
 
You could react to mouse click through the MouseUp event instead of the Click event.

Private Sub grdDataGrid_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Y > 300 Then 'this depends how heigh the headline is
MsgBox "Normal click"
End If
End Sub



Eman_2005
Technical Communicator
 
Yes, I may be able to do something with that. It is one of those VB 'things' you wonder why they are there since you never found a use for them. Thanks for the lead!

Steve
 
Alternatively you can code the datagrid click event not to fire unless there is a row selected:
Code:
If grdDataGrid.Row > -1 then....

HTH

TazUk

[pc] Blue-screening PCs since 1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top