You just want the value contained within a certain cell, correct? Fairly simple; use the DataGrid's indexer. Here's how to do it in C#:
Object val = dataGrid1[row, col];
And I think this is what it looks like in VB (I'm not a VB fan, though, so bear with me)
Dim val As Object = dataGrid1(row, col)
Just pass a valid row and column. To get the current cell's value, just replace "row, col" with dataGrid1.CurrentCell, so it'll look something like this in VB:
Dim val As Object = dataGrid1(dataGrid1.Curren
Hope that helps,
Nate
Main Topics
Browse All Topics





by: iboutchkinePosted on 2009-06-18 at 12:44:54ID: 24661092
Cell value
EventArgs) Handles dg.MouseDown
, hti.Column).ToString())
Value = dg.Item(iRow, lCol)
If you want the clicked cell value then
Private Sub dg_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.Mouse
' X & Y are in the grid' coordinates. If they are in screen coordinates, call dataGrid1.PointToClient method
Dim pt As Point = 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
End If
End If
End Sub