问题描述
我正在使用C#WinForm.我正在尝试格式化DataGridViewButtonColumn
,但是此代码未设置Text
属性或设置BackColor
和ForeColor
.代码如下:
I''m using C# WinForm. I''m trying to format my DataGridViewButtonColumn
but this code is not setting the Text
property or setting the BackColor
and ForeColor
. Here''s the code:
private void Form1_Load(object sender, EventArgs e)
{
DataGridViewButtonColumn btnStop = new DataGridViewButtonColumn();
btnStop.Name = "btnStop";
btnStop.Text = "STOP";
btnStop.HeaderText = "Stop";
btnStop.UseColumnTextForButtonValue = true;
btnStop.CellTemplate.Style.ForeColor = Color.Red;
btnStop.CellTemplate.Style.BackColor = Color.White;
dgvDisplay.Columns.Add(btnStop);
}
这开始变得非常愚蠢!我将FlatStyle
属性设置为"Popup
",并且现在已设置BackColor
,但是在所有其他FlatStyle
项下BackColor
都不会设置,只有按钮周围的边框会改变颜色和Text
仍不显示.
This is starting to get very silly! I set the FlatStyle
property to "Popup
" and the BackColor
is now being set, but under all other FlatStyle
''s the BackColor
won''t set, only the border around the button changes color and Text
is still not displaying.
Anyone out there know how to set these properties?
推荐答案
这篇关于dataGridViewButtonColumn格式不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!