开发者

store datagridview column value in a variable

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜