我有一個模式窗口中的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