this.grd1.Rows[i].Cells["列名"].BackColor="颜色";这句编译不过去。用过的指点一下啊
12 个解决方案
#1
没人回答么?在线等
#2
dgr = headerUnitView1.Rows[i];
drc = headerUnitView1.Columns[j];
// MessageBox.Show(drc.ToString());
drc.HeaderCell.Style.BackColor = Color.Red;
headerUnitView1[j, i].Style.BackColor = Color.Red;
drc = headerUnitView1.Columns[j];
// MessageBox.Show(drc.ToString());
drc.HeaderCell.Style.BackColor = Color.Red;
headerUnitView1[j, i].Style.BackColor = Color.Red;
#3
headerUnitView1是什么?是自定义的gridview的名字么?编译不过去啊,LS用的是DevExpress gridview 控件么,不够我可以在加分啊
#4
参考下面的代码,当值是"0"的单元格的前景色为白色,背景色为黑色表示。
代码来自 http://bingning.net/free/source/datagrid/coloredcell.html
代码来自 http://bingning.net/free/source/datagrid/coloredcell.html
// DataGridTextBoxColumn继承类作成
public class MyDataGridTextBoxColumn : DataGridTextBoxColumn
{
// Paint方法重载
protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum, Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
//取得单元格的值
object cellValue =
this.GetColumnValueAtRow(source, rowNum);
if (cellValue != null)
{
//值是"0"的单元格的前景色和背景色改变
if ((string) cellValue == "0" && cellValue != DBNull.Value)
{
foreBrush = new SolidBrush(Color.White);
backBrush = new SolidBrush(Color.Black);
}
}
//调用基本类的Paint方法
base.Paint(g, bounds, source, rowNum,
backBrush, foreBrush, alignToRight);
}
}
#5
快下班了,高手指点一下啊
#6
用CustomDrawCell事件
#7
this.dgvstuInfos.AlternatingRowsDefaultCellStyle.BackColor = Color.PaleGoldenrod;
#8
顶
字数补丁.exe
字数补丁.exe
#9
ding!!
#10
帮结贴!
#11
private void gvProduct_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
DevExpress.Utils.AppearanceDefault appNotPass1 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Salmon, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
DevExpress.Utils.AppearanceDefault appNotPass2 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Yellow, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
DevExpress.Utils.AppearanceDefault appNotPass3 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Green, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
if (e.Column.FieldName == "Available")
{
DataRow dr = gvProduct.GetDataRow(e.RowHandle);
string strTemp = dr[e.Column.FieldName].ToString().Trim();
if (!string.IsNullOrEmpty(strTemp))
{
switch (strTemp)
{
case "保存未提交": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass1); break;
case "审核未通过": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass1); break;
case "提交未审核": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass2); break;
case "审核通过": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass3); break;
}
}
}
}
#12
现在有人解决了吗?求解。。。。。
#1
没人回答么?在线等
#2
dgr = headerUnitView1.Rows[i];
drc = headerUnitView1.Columns[j];
// MessageBox.Show(drc.ToString());
drc.HeaderCell.Style.BackColor = Color.Red;
headerUnitView1[j, i].Style.BackColor = Color.Red;
drc = headerUnitView1.Columns[j];
// MessageBox.Show(drc.ToString());
drc.HeaderCell.Style.BackColor = Color.Red;
headerUnitView1[j, i].Style.BackColor = Color.Red;
#3
headerUnitView1是什么?是自定义的gridview的名字么?编译不过去啊,LS用的是DevExpress gridview 控件么,不够我可以在加分啊
#4
参考下面的代码,当值是"0"的单元格的前景色为白色,背景色为黑色表示。
代码来自 http://bingning.net/free/source/datagrid/coloredcell.html
代码来自 http://bingning.net/free/source/datagrid/coloredcell.html
// DataGridTextBoxColumn继承类作成
public class MyDataGridTextBoxColumn : DataGridTextBoxColumn
{
// Paint方法重载
protected override void Paint(Graphics g,
Rectangle bounds,
CurrencyManager source,
int rowNum, Brush backBrush,
Brush foreBrush,
bool alignToRight)
{
//取得单元格的值
object cellValue =
this.GetColumnValueAtRow(source, rowNum);
if (cellValue != null)
{
//值是"0"的单元格的前景色和背景色改变
if ((string) cellValue == "0" && cellValue != DBNull.Value)
{
foreBrush = new SolidBrush(Color.White);
backBrush = new SolidBrush(Color.Black);
}
}
//调用基本类的Paint方法
base.Paint(g, bounds, source, rowNum,
backBrush, foreBrush, alignToRight);
}
}
#5
快下班了,高手指点一下啊
#6
用CustomDrawCell事件
#7
this.dgvstuInfos.AlternatingRowsDefaultCellStyle.BackColor = Color.PaleGoldenrod;
#8
顶
字数补丁.exe
字数补丁.exe
#9
ding!!
#10
帮结贴!
#11
private void gvProduct_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
DevExpress.Utils.AppearanceDefault appNotPass1 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Salmon, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
DevExpress.Utils.AppearanceDefault appNotPass2 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Yellow, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
DevExpress.Utils.AppearanceDefault appNotPass3 = new DevExpress.Utils.AppearanceDefault(Color.Black, Color.Green, Color.Empty, Color.SeaShell, System.Drawing.Drawing2D.LinearGradientMode.Horizontal);
if (e.Column.FieldName == "Available")
{
DataRow dr = gvProduct.GetDataRow(e.RowHandle);
string strTemp = dr[e.Column.FieldName].ToString().Trim();
if (!string.IsNullOrEmpty(strTemp))
{
switch (strTemp)
{
case "保存未提交": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass1); break;
case "审核未通过": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass1); break;
case "提交未审核": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass2); break;
case "审核通过": DevExpress.Utils.AppearanceHelper.Apply(e.Appearance, appNotPass3); break;
}
}
}
}
#12
现在有人解决了吗?求解。。。。。