Windows forms Datagrid cell text

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
 
R

Richard Harris

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

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top