Display DataTable content reversely

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello.

I want to display the content of 'displayTable' object reversely.
When from r=0 to r= displayTable.Length-1, the code works well to display.
But when from r= displayTable.Length-1 to r=0, the code doesn't work to
display.

Thanks a lot for any help.

**********
DataRow[] displayTable = resultTb.Select();
....
//for (int r = 0 ; r < displayTable.Length ; r++ ) // works well.
//for (int r = 6 ; r < -1 ; r = r-1 ) // doesn't work
for (int r = displayTable.Length-1 ; r < -1 ; r--) // doesn't work
{
...
buttonNm = displayTable[r].ItemArray.GetValue(3).ToString().Trim();
this.openButton = new System.Windows.Forms.Button();
this.Controls.Add(this.openButton);
...
}
*************
Have a nice day.

Eunice.
 
Hello,
revise the for loop. it says that the statements will only execute
when r will be less than -1. I hope you wanna use it like this:
for (int r = displayTable.Length-1 ; r > -1 ; r--)

HTH. Cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
 
Hi,
I dont see any problem in your code. Except
Replace:for (int r = displayTable.Length-1 ; r < -1 ; r--)

with: for (int r = displayTable.Length-1 ; r > -1 ; r--)

It should be r>-1.
 

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

Back
Top