Click here to Skip to main content
14,301,556 members
Rate this:
Please Sign up or sign in to vote.
I Have a datagridview like this

id name age
-----------
1 AAA 22
2 BBB 23
3 CCC 33
4 DDD 44

I want to add id values to an int array on click of id cell..

thx in advance...
Posted

1 solution

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

Solution 1

I think it will be easy to add the IDs to a list. However, if you want an array ToArray() method of List<T>class can be used.

List<int> IdList = new List<int>();

private void dataGridView1_CellClick(object sender,
    DataGridViewCellEventArgs e)
{
    IdList.Add(Convert.ToInt32(dataGridView1.Rows[e.RowIndex]
        .Cells[e.ColumnIndex].Value));
}
   
v3
Comments
Ravi Sargam 15-Mar-12 5:05am
   
Thank you... it's working...
Thx again
ProEnggSoft 15-Mar-12 5:24am
   
Thank you
Ravi Sargam 15-Mar-12 5:32am
   
Hey Can you find solution for this question "add group's total values in Crystal Reports and show in same report
"
ProEnggSoft 15-Mar-12 8:17am
   
Sorry, I am not using Crystal Reports. Thank you
ProEnggSoft 15-Mar-12 8:16am
   

To the member who has downvoted:

Can you please give the reason for down voting, to know what is the deficiency.

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




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