newbie: Navigating through a datagrid

S

steve

Hi,
I don't seem to find any direct methods of navigating in a datagrid after
it has been populated.
How would I use a double nested loop to navigate through all the rows and
columns and count or store the various cells?

Do I have to do it directly on the dataset that was used to bind the
datagrid?

Thanx in advance,
steve
 
C

Cor Ligthert

Steve,
Do I have to do it directly on the dataset that was used to bind the
datagrid?
Exactly or better expressed using the datasource from the datagrid

Cor
 
S

steve

Thanx Cor!
But what annoyes me is that i dont seem to be able to do:

For i As Integer = 0 To myDataSet.Tables("tblDisp").Rows.Count - 1

For j As Integer = 0 To myDataSet.Tables("tblDisp").Columns.Count - 1

myVariable= myDataSet.Tables("tblDisp").Columns(j).Rows(i).item <--wrong code !

Next

Next

or something like that !!!!!!

Why?????

All i want is to scan and navigate.... why should it be so difficult?
 
C

Cor Ligthert

Steve


For i As Integer = 0 To myDataSet.Tables("tblDisp").Rows.Count - 1
For j As Integer = 0 To myDataSet.Tables("tblDisp").Columns.Count - 1
myVariable= myDataSet.Tables("tblDisp").Rows(i)(j).tostring
Next
Next

Why?????

Columns are to describe items not to reference to.

Items are to get the data.

When it does not work now than it is a typo.

I hope however that this helps direct?

Cor
 
S

steve

Damn! I feel stupid!!!
But i swear i looked everywhere on MSDN and Google, couldn't find something
like that.
(i still feel Rows(i).Columns(j) is more intuitive but...thats me)
I know that most applications once they extract the data they just print
them or store them at Excel. But i would imagine many people would want to
store them in arrays and perform various statistics, etc. on them. Am I an
exception !??

Thanx a lot Cor!
You saved the day *again*!
-steve
 

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