CurrentRowIndex always returns Zero.

B

Bill Fisher

Disclaimer, I am very, VERY new to .net.

I am currently working with vb.net Visual Studio 2003.and I have a
problem with the CurrentRowIndex property of the DataGrid control.

I load an xml file to a data grid (dgMenu) like this:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim ds As DataSet = New DataSet

ds.ReadXml("C:\APOS\MenuFile\test.xml",
XmlReadMode.InferSchema)

dgMenu.DataSource = ds

End Sub

So far so good. But when I try read the CurrentRowIndex property of
dgMenu in the code below it always returns zero.

Private Sub dgMenu_CurrentCellChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles dgMenu.CurrentCellChanged


dgMenu.Select(dgMenu.CurrentCell.RowNumber)
MessageBox.Show(dgMenu.CurrentRowIndex)

End Sub

Why is CurrentRowIndex zero in this context? My assumption has been
that it points to the currently selected row in the grid. Am I wrong?

I would appreciate your comments.
Thank you
bf
 

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