在 DataGridView 控件中设置行名称?
VB.Net 的 DataGridView 支持命名列,但我想知道它是否可以以某种方式对行执行相同的操作,以便我们可以使用如下内容:
With DataGridView1
.Rows.Add(4)
.Rows(0).Name = "Setting1"
.Rows(1).Name = "Setting2"
'Added two columns at design time
.Columns("Key").Row("Setting1") = "Key1"
.Columns("Value").Row("Setting1") = "Value1"
.Columns("Key").Row("Setting2") = "Key2"
.Columns("Value").Row("Setting2") = "Value2"
End With
您是否确认这是不可能的,我们必须使用数字索引来引用行号?
VB.Net's DataGridView supports naming columns, but I was wondering if it could somehow do the same for rows, so that we could use something like this:
With DataGridView1
.Rows.Add(4)
.Rows(0).Name = "Setting1"
.Rows(1).Name = "Setting2"
'Added two columns at design time
.Columns("Key").Row("Setting1") = "Key1"
.Columns("Value").Row("Setting1") = "Value1"
.Columns("Key").Row("Setting2") = "Key2"
.Columns("Value").Row("Setting2") = "Value2"
End With
Do you confirm that it's not possible and we must use numeric indexes to refer to row numbers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DataGridViewRow
上没有Name
属性,所以不,这是不可能的。您始终可以使用
Dictionary
将名称绑定到DataGridViewRow
:There is no
Name
property onDataGridViewRow
, so no, it's not possible.You could always use a
Dictionary
to tie a name to aDataGridViewRow
:存在一种使用 .Value 来做到这一点的方法
exist a way to do this using .Value