
Capture click/double-click events from datatable
If you are talking about datagrid (not datatable ) her ethe code to capture
click event
Private Sub dg_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles dg.MouseDown
' X & Y are in the grid' coordinates. If they are in screen
coordinates, call dataGrid1.PointToClient method
Dim pt = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = dg.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
'cell text)
MessageBox.Show(dg(hti.Row, hti.Column).ToString())
'row number
MsgBox((dg.CurrentCell.RowNumber).ToString)
'col number
MsgBox((dg.CurrentCell.ColumnNumber).ToString)
Else
'header name ( column)
If hti.Type = DataGrid.HitTestType.ColumnHeader Then
MsgBox(ds.Tables(0).Columns(hti.Column).ToString)'ds defined
earlier
End If
End If
End Sub
Quote:
> Randy,
> If you want, you can subclass the DataGrid class and then override the
> WndProc method, looking for the double click mouse message. Once you get
> that, you can process it any way you want. Just make sure that you call
the
> base class implementation for messages that you aren't looking to process
> specifically.
> Hope this helps.
> --
> - Nicholas Paldino [.NET/C# MVP]
> > Hi,
> > How can I capture the click/double-click events from a datatable. There
> are
> > a few listed events in the datable, but nothing mentioned about mouse
> > events.
> > Thanks in advance,
> > Randy