我在模式窗口中有一个 DataGridView,其中包含我的程序的选项列表。网格有两个列。第一个包含用于选择该选项的复选框,第二个是该选项的名称/描述。winform 还包含确定和取消按钮,但这不是重点。下面的代码做了我想要的。由于 FullRowSelect 属性,复选框被选中/取消选中,您单击该行内的任意位置。但是,它不再在当前行周围显示蓝色背景或虚线。我如何能够在不丢失任何当前功能的情况下添加它?
编辑:详细说明;我想要的是再次启用所选行/单元格上的虚线和/或蓝色背景。看起来我目前的代码以某种方式禁用了这个......
相关当前代码:
public OptionsForm()
{
InitializeComponent();
OptionsRoot = Options.GetReadOnlyRoot(OptionsBannersNameValueList.GetNameValueList(Settings.Default.OptionsBanners));
optionsBannersDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
optionsBannersDataGridView.MultiSelect = false;
optionsBannersDataGridView.RowPrePaint += new DataGridViewRowPrePaintEventHandler(optionsBannersDataGridView_RowPrePaint);
InitUI();
Closing += MyFormClosing;
BindingSourceTree = BindingSourceHelper.InitializeBindingSourceTree(components, rootBindingSource);
}
private void optionsBannersDataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
e.PaintParts &= ~DataGridViewPaintParts.Focus;
}