问题描述
我想用我的的DataGridView
只显示的东西,我希望用户不能够从<$ C $选择任何行,场或任何C>的DataGridView 。
我怎样才能做到这一点?
我会用这个去:
私人无效dgvSomeDataGridView_SelectionChanged(对象发件人,EventArgs的)
{
dgvSomeDataGridView.ClearSelection()
}
我不与广泛的说法一致认为,没有的DataGridView
应该是不可选择的。一些用户界面是专为工具或touchsreens,并允许选择误导用户认为,选择将真正得到他们的地方。
设置只读=真正的
上的控制对一个单元格或行是否可以选择没有影响。并且有视觉和功能缺点制定已启用=假
。
另一种选择是在控制设置选择的颜色是什么非选择颜色,但如果碰巧被操纵电池的背面的颜色,则此方法产生一些讨厌结果,以及对>
I want to use my DataGridView
only to show things, and I want the user not to be able to select any row, field or anything from the DataGridView
.
How can I do this?
I'd go with this:
private void dgvSomeDataGridView_SelectionChanged(Object sender, EventArgs e)
{
dgvSomeDataGridView.ClearSelection()
}
I don't agree with the broad assertion that no DataGridView
should be unselectable. Some UIs are built for tools or touchsreens, and allowing a selection misleads the user to think that selecting will actually get them somewhere.
Setting ReadOnly = true
on the control has no impact on whether a cell or row can be selected. And there are visual and functional downsides to setting Enabled = false
.
Another option is to set the control selected colors to be exactly what the non-selected colors are, but if you happen to be manipulating the back color of the cell, then this method yields some nasty results as well.
这篇关于如何禁用一个DataGridView选择的能力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!