在C#数据网格的行和列数 [英] Row and Column count of data grid in C#

查看:78
本文介绍了在C#数据网格的行和列数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑我有一个数据网格,我需要找到在数据网格行和coulmns数。我如何在C#这样做吗?

Consider I have a data grid, I need to find the number of rows and coulmns in the data grid. How can I do this in C#?

推荐答案

DataGrid.Items 属性返回一个 DataGridItemCollection 代表 DataGridItems 在DataGrid中。

The DataGrid.Items property returns a DataGridItemCollection representing the DataGridItems in the DataGrid.

每个的DataGridItem 为代表的呈现表中单列。此外,的DataGridItem 公开表示无一单元属性。作者tablecells(换句话说,列)在呈现表

Each DataGridItem is representative of a single row in the rendered table. Also, the DataGridItem exposes a Cells property which represents the no. of tablecells (in other words, the columns) in the rendered table.

int rowCount = myGrid.Items.Count;

// Get the no. of columns in the first row.
int colCount = myGrid.Items[0].Cells.Count;

这篇关于在C#数据网格的行和列数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆