[英]C# WinForms: Adding rows to a dataGridView
I've just started to use dataGridView, and some things seem strange to me: 我刚刚开始使用dataGridView,对我来说有些事情似乎很奇怪:
If it is only possible to add rows programmatically, I have this question: 如果只能以编程方式添加行,则我有以下问题:
update: About disabling sorting, I found out myself: there is a property to change this if you open the (Collections) of the columns. 更新:关于禁用排序,我发现自己:如果打开列的(集合),则可以更改此属性。
You can add Rows by calling dataGridView1.Rows.Add();
您可以通过调用
dataGridView1.Rows.Add();
添加行dataGridView1.Rows.Add();
. 。 For multiple rows there is an overload for the same available.
对于多行,相同的可用过载。
dataGridView1.Rows.Add(5);
Now to fill the dataGridView1
rows you can either assign a DataSource and set the DataPropertyName
for the Column. 现在要填充
dataGridView1
行,您可以分配一个DataSource并设置Column的DataPropertyName
。 Else loop through and fill the data cell wise like dataGridView1[columnindex,rowindex].Value =something
否则,像
dataGridView1[columnindex,rowindex].Value =something
那样循环遍历并填充数据单元格dataGridView1[columnindex,rowindex].Value =something
The star icon shows the current row which is being edited, you can choose to hide that cell by setting the RowHeadersVisible
to false. 星号图标显示正在编辑的当前行,您可以通过将
RowHeadersVisible
设置为false来选择隐藏该单元格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.