我已经搜索了很多关于这个问题的答案。这篇文章的答案:更改 DataGridView 单元格中按钮的颜色没有回答我的问题,因为它与字体有关。
我尝试了以下方法:
DataGridViewRow r = dataGridView.Rows[0];
r.Cells[1].Style.BackColor = Color.Red;
Run Code Online (Sandbox Code Playgroud)
我也试过:
DataGridViewButtonColumn btnCOl = new DataGridViewButtonColumn();
btnCOl.FlatStyle = FlatStyle.Popup;
DataGridViewRow r = dataGridView.Rows[0];
r.Cells[1].Style = new DataGridViewCellStyle { BackColor = Color.LightBlue };
Run Code Online (Sandbox Code Playgroud)
还是无济于事。
我还注释掉了这一行:
// Application.EnableVisualStyles();
Run Code Online (Sandbox Code Playgroud)
如果有人知道如何更改 DataGridViewButtonColumn 中单个按钮的背景颜色,请帮忙。
编辑: 我想为列中的单元格设置不同的颜色,例如有些是红色,有些是绿色。我不想为整列设置颜色。
如何将数字转换为科学记数法并获得指数?例如,如果我有 23582 并想将其转换为 2.3582 x 10^4,然后获得数字顺序的“4”?(我正在使用 C#)