有没有办法阻止用户在特定的dgvRow中选择单元格。
行是只读的,但仍然可以选择。c#winforms - 如何使DataGridViewRow UnSelectable?
1
A
回答
2
您可以添加一个自定义委托,在选择更改时取消选择有问题的单元格。
DataGridView1.SelectionChanged += new EventHandler(DataGridView1_SelectionChanged);
private void DataGridView1_SelectionChanged(object sender, EventArgs e){
List<DataGridViewCell> toBeRemoved = new List<DataGridViewCell>();
foreach(DataGridViewCell selectedCell in DataGridView1.SelectedCells){
if (isCellUnSelectable(selectedCell))
toBeRemoved.Add(selectedCell);
}
foreach(DataGridViewCell cell in toBeRemoved){
cell.Selected = false;
}
}
+0
不能相信dgv没有这样的builtIn属性。 AnyWay,都感谢。 – Bonaca
+0
dgv无法创建此属性,因为dgv的内容是动态分配的,这意味着它在给定单元格上没有静态句柄。如果您尝试添加单元格并使其不可选,则必须围绕要删除的单元格设计dgv,并重新设计另一个类似的单元格,从而使单个单元格的可选属性无法跟踪。 –
相关问题
- 1. c#make textbox unselectable
- 2. 如何添加ComboBox到C#中的DataGridViewRow?
- 3. 如何跳过DataGridViewRow?
- 4. 如何使用C#和WinForms
- 5. 在C中扩展DataGridViewRow#
- 6. 如何从DataGridViewRow填充DataGridView
- 7. 如何取消共享Datagridviewrow
- 8. C#的WinForms如何使用按钮
- 9. 如何插入使用DataGridView - C#winforms?
- 10. 如何在WinForms C#中使用线程?
- 11. C#如何使设置阵列WinForms
- 12. Drupal,Views,Exposed filter,make tags unselectable
- 13. 如何在C#中的WinForms
- 14. C#:将DataGridViewRow添加到DataGridView异常
- 15. DataGridViewRow到表格
- 16. 如何从CellFormatting事件中获取DataGridViewRow?
- 17. 如何记住DataGridViewRow隐藏属性
- 18. 按值复制DataGridViewRow?
- 19. DataGridViewRow选择操作
- 20. 更改DataGridViewRow的BackColor
- 21. DataGridViewRow数值顺序
- 22. 如何使用带有DataGridViewRow列表的BindingSource DataSource?
- 23. 在C++/CLI(WinForms)应用程序中使用C#WinForms控件
- 24. 使用winforms的C#Datagridview
- 25. 在C#Winforms中使用SaveFileDialog
- 26. c#winforms events
- 27. 如何在IE10中用css覆盖unselectable =“on”?
- 28. c#Winforms MVC
- 29. Winforms如何使用Presentation Model?
- 30. 如何使用CefSharp的WinForms
也许javascript阻止用户点击它......无论如何,这个决定背后的逻辑是什么?因为你知道,在互联网上发布的所有东西,无论你做什么,它都可以被复制和共享。如果您禁止用户单击(并复制和粘贴),用户仍然可以访问源代码并执行他/她想要的任何操作。 – walther