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

Datagrid Problem

Status
Not open for further replies.

vpaladan

Programmer
Nov 13, 2002
13
PH
Hi,

Does anybody know why the datagrid click event is triggered when datagrid HeadClick event is initiated.

Is there any work around to this problem? or kindly advice alternative controls, any grid controls that i can click on its column header or row/row headers.

For your info, id like to display the records based on column header (by clicking on the column header) and clicking on the row/row header to show another form/page to edit the record.

Thanks

Vic
 
The Click event is raised because you did indeed click on the grid. Instead of the Click event, use a MouseDown event with code like
[blue][tt]
Private Sub grdxxx_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo NotInTheGrid
grdxxx.Row = grdxxx.RowContaining(y)
' ... Process Click related code ...
Exit Sub
NotInTheGrid:
End Sub
[/tt][/blue]
That will process the click if it's within the grid but will bypass the click code if you clicked on the grid control but not within the body of the control such as on a column header.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top