Windows forms Datagrid cell text

  • Thread starter Thread starter Richard Harris
  • Start date Start date
R

Richard Harris

Hi,

I am trying to write some code that will return the text from a datagrid
cell when you click on it. So far I have the following code (which maybe
completely the wrong way to go about this), which returns the row number,
and the column number, but I am not sure how to get the contents of the cell
from this.

///
Private Sub dg1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Dg1.MouseUp
'Returns the room for the datagrid row that has been clicked
Dim pt = New Point(e.X, e.Y)
Dim hti As DataGrid.HitTestInfo = Dg1.HitTest(pt)
If hti.Type = DataGrid.HitTestType.Cell Then
MsgBox(hti.Row & " " & hti.Column)
Endif
///

Thanks
Richard
 
I knew there would be an easy solution! Thanks very much for your help.

Richard
 
Back
Top