本文介绍了dataGridViewButtonColumn格式不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#WinForm.我正在尝试格式化DataGridViewButtonColumn ,但是此代码未设置Text 属性或设置BackColorForeColor.代码如下:

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格式不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 11:22
查看更多