开发者

store datagridview column value in a variable

开发者 https://www.devze.com 2023-03-01 09:28 出处:网络
I want to store the column values (to be precise two column values in two variables). How this can be ac开发者_如何学Chieved. Any sample code will be of great help. Thanks.You can do it like this:

I want to store the column values (to be precise two column values in two variables). How this can be ac开发者_如何学Chieved. Any sample code will be of great help. Thanks.


You can do it like this:

var column1 = dataGrid.Rows[0].Cells["Called Number"].Value;
var column2 = dataGrid.Rows[0].Cells["Callee Number"].Value;

If you know the specific type (String, int, etc.) you can do some sort of conversion if you want:

int column1 = Int32.Parse(dataGrid.Rows[0].Cells["Called Number"].Value.ToString());
int column2 = Int32.Parse(dataGrid.Rows[0].Cells["Callee Number"].Value.ToString());
0

精彩评论

暂无评论...
验证码 换一张
取 消