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

相关问题