datagridview第一列背景色为 255 106 46怎么写

来源:百度知道 编辑:UC知道 时间:2024/05/29 02:51:38

楼上理解错lz的意思了,是datagridview
----
以下希望能帮助lz
dataGridView1.Columns[0].DefaultCellStyle.BackColor = Color.FromArgb(255, 106, 46);

你说的是窗体加载的时候设置还是按了按钮以后设置
这是窗体加载的时候设置自动编号的
那么既然能自动编号 那么自动颜色应该对你来说不是问题吧?
if (e.Row.RowIndex != -1)
{
int id = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = id.ToString();
}

按了按钮以后
//获得选择的一行的ID
ImageButton imageButton = new ImageButton();
imageButton = (ImageButton)sender;
int rowIndex = ((GridViewRow)imageButton.NamingContainer).RowIndex;
Label label = (Label)this.GrdCompany.Rows[rowIndex].Cells[1].FindControl("LblUserIdFromUpDate");
string id = label.Text;
这样能设置TEXT了 那么设置颜色没问题吧?

我告诉你这么多 希望你能举一反三 如果实在是不明白 直接百度HI我