DataGridView Indexes

In VS Express Edition

Page 1 of 1

2 Replies - 996 Views - Last Post: 25 January 2010 - 10:59 AM Rate Topic: -----

#1 boris_rk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 22-January 10

DataGridView Indexes

Post icon  Posted 25 January 2010 - 08:22 AM

I need a way to set DataGridView row (for example) index to a desired value. In practise, I need a code behind the buttons 'first','previous','next' and 'last' that operate row selection in the data grid view.

I got accustomed an earlier version of C# and now I just can't discover a way to do the same things in the new version...
Is This A Good Question/Topic? 0
  • +

Replies To: DataGridView Indexes

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: DataGridView Indexes

Posted 25 January 2010 - 08:39 AM

private void btnNext_Click(object sender, EventArgs e)
{
	 int index = dataGridView.SelectedRows[0].Index;
	 dataGridView.Rows[index + 1].Selected = true;
}



you will need to do some checking like whether the user has actually selected a row, and checking to make sure that "index + 1" isn't out of range for the rows.

This post has been edited by eclipsed4utoo: 25 January 2010 - 08:40 AM

Was This Post Helpful? 0
  • +
  • -

#3 boris_rk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 22-January 10

Re: DataGridView Indexes

Posted 25 January 2010 - 10:59 AM

Yup tht solved the problem, thank you again eclipsed4utoo :^: :^: :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1