在单元格单击上将DataGridView值添加到int数组 [英] Add DataGridView values to int array on cell click
本文介绍了在单元格单击上将DataGridView值添加到int数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像这样的datagridview
id名称age
-----------
1 AAA 22
2 BBB 23
3 CCC 33
4 DDD 44
我想在单击id单元格时将id值添加到int数组..
提前thx ...
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...
推荐答案
我认为将ID添加到列表中会很容易.但是,如果要使用List<T>
class的数组ToArray()
方法.
I think it will be easy to add the IDs to a list. However, if you want an arrayToArray()
method ofList<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));
}
这篇关于在单元格单击上将DataGridView值添加到int数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文