我有一个模式窗口中的DataGridView和我的程序的选项列表。网格有两个柱子。第一个包含用于选择该选项的复选框,第二个是该选项的名称/描述。该winform还包含确定和取消按钮,但这是重点。下面的代码做我想要的。由于FullRowSelect属性的复选框被选中/未选中,因此您可以在该行中单击任意位置。但它不会在当前行周围显示蓝色背景或虚线。我将如何在不失去任何当前功能的情况下添加此功能?DataGridView: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;
}
这会确保最上面一行是加载时的蓝色,但? – Sakkle 2009-04-30 09:37:56