Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
How can i retrieve the number of row from datagridview.
 
If I use this.
var a=  dataGridView1
 
I can't complete the code to retrieve the number of index to use it.
Posted 17-Nov-12 5:19am
Edited 17-Nov-12 6:04am
RaisKazi32.8K
v2
Comments
@AmitGajjar at 17-Nov-12 11:43am
   
you want number of rows or number of columns ?
meme_307 at 17-Nov-12 11:45am
   
i want number of row to use it in update and delete
Sergey Alexandrovich Kryukov at 17-Nov-12 23:18pm
   
What is "number of index"? :-)
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
meme_307 at 17-Nov-12 13:00pm
   
var row = dataGridView1.CurrentCell.RowIndex;
label3.Text = row;
i want to use like this to retrieve the number of row but it give me error
meme_307 at 17-Nov-12 13:05pm
   
i want to save the index of row in database
ridoy at 17-Nov-12 13:43pm
   
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int rowIndex1 = e.RowIndex;
int rowIndex2 = GetRowIndex();
}
private int GetRowIndex()
{
int rowIndex = this.dataGridView1.CurrentCell.RowIndex;
return rowIndex;
}
I use here 2 ways to find out index..i think you can easily convert it to vb.net..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 432
1 Kornfeld Eliyahu Peter 420
2 Yogesh Kumar Tyagi 244
3 Nelek 115
4 Gihan Liyanage 99
0 Kornfeld Eliyahu Peter 420
1 OriginalGriff 303
2 Yogesh Kumar Tyagi 230
3 Gihan Liyanage 99
4 sankarsan parida 90


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 17 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100