EmersonH.Com

Transforming Knowledge into Power

  • Increase font size
  • Default font size
  • Decrease font size
Home VB.Net 2008 DataGridView Getting current cell

Getting current cell

E-mail Print
Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Uses Test class from above.
Dim list = New List(Of Test)
list.Add(New Test("Mac", 2200))
list.Add(New Test("PC", 1100))
DataGridView1.DataSource = list
End Sub

Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
' Get the current cell location.
Dim y As Integer = DataGridView1.CurrentCellAddress.Y
Dim x As Integer = DataGridView1.CurrentCellAddress.X

' Write coordinates to console.
Console.WriteLine(y.ToString + " " + x.ToString)
End Sub
End Class
Last Updated on Monday, 21 December 2009 17:40