473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

CurrentRowIndex always returns Zero.

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
Dec 9 '07 #1
1 1689
Bill,

Even if you was not wrong then this is very unsiffucient code. People can
sort the grid, therefore, try a dataview between it and use the Current
possition.

Have a look at this tip

http://www.vb-tips.com/DataGridRowChange.aspx
Cor

"Bill Fisher" <no****@somewhere.comschreef in bericht
news:jn********************************@4ax.com...
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
Dec 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bob Smith | last post by:
question in subject. does the standard say anything about this or is it platform dependent? any advice much appeciated /B
25
by: Mantorok Redgormor | last post by:
Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. beyond this...
22
by: Fred Ma | last post by:
I'm using the expression "int a = ceil( SomeDouble )". The man page says that ceil returns the smallest integer that is not less than SomeDouble, represented as a double. However, my...
5
by: Tim | last post by:
Hello All, I am writing a program that checks for the NumLock status and turns the NumLock on if it is off. I'm not sure what I'm overlooking at this point, but the code will compile and run, but...
1
by: .NETn00b | last post by:
I am trying to convert the following windows app method, to use in an ASP.NET application: private void DataGrid1_CurrentCellChanged(object sender, EventArgs e) { int c =...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
4
by: eva.monsen | last post by:
I'm trying to run a .BAT file using System.Diagnostics.Process. I'm having trouble getting Process.ExitCode to match up with what the .BAT file returns. Here are the contents of...
12
by: arnuld | last post by:
#include <stdio.h> int main() { printf("%d\n", getchar() != EOF); return 0; } when i run this programme, no matter what i give it as input, output
11
by: active | last post by:
The code below does much as expected. For example biSize=40 but biClrUsed is always zero!
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.