3

我在Windows窗體中創建了一個客戶端應用程序。我已經使用Windows Server 2008 R2進行開發。DataGridViewComboBoxColumn在Windows 7 + OS上的行爲不同

然而,客戶端報告了一些錯誤,我無法在我的機器上重現這些錯誤,但是當我在Windows 7或10上部署相同的解決方案時,它給了我不同的結果。

截至目前,我現在兩個問題:

  1. DataGridViewComboBoxColumn backcolour原來是灰色的。
  2. 使用Tabs或Cursors鍵在列間移動時,它們跳過組合框列。 這是最大的問題。

我用最少的代碼創建了一個測試應用程序,發現這個問題仍然存在於測試應用程序中。

DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn(); 
{ 
    column.HeaderText = "CB"; 
    column.Name = "CB"; 
    column.DefaultCellStyle.BackColor = Color.White; 
    //column.CellTemplate = new DataGridViewCheckBoxCell(); 
    column.DataSource = list; 
    column.ValueType = typeof(string); 

} 

dataGridView1.Columns.Add(column); 

dataGridView1.DataSource = dtEmp; 

這裏的問題截圖:

的Windows 10 - 請注意,儘管移動光標鍵,第一列不突出
enter image description here
的Windows 2008-注意dfirst列高亮顯示,細胞不會變灰。
enter image description here

任何幫助將不勝感激。

回答

0

您可能會嘗試將DisplayStyle屬性更改爲Nothing枚舉值,以便您的列將按樣式設置並且焦點將可見。但是,組合框箭頭顯然會消失,但這對您來說可能不是問題。

this.Column1.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing; 

Result

或嘗試FlatStyle屬性更改爲Flat,這樣你會看到一個組合框箭頭:

this.Column1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 

Flat

+0

謝謝。這工作像一個魅力 this.Column1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; – Shaan

相關問題