DEV GridControl绑定的数据,ID相同的行显示相同的颜色(当可以确定ID的值时)
2012-07-24 23:16
423 查看
public BindingList<StudentDC> StudentList
{
get { return this.bindingSourceList.DataSource as BindingList<StudentDC>; }
set { bindingSourceList.DataSource = value; }
}
private void FrmGridTest_Load(object sender, System.EventArgs e)
{
StudentList = GetStudentList();
}
private BindingList<StudentDC> GetStudentList()
{
BindingList<StudentDC> list = new BindingList<StudentDC>(){
new StudentDC(){Class = "Class 1",ID = 1,Name = "zhangsan"},
new StudentDC(){Class = "Class 1",ID = 1,Name = "zhangsan"},
new StudentDC(){Class = "Class 2",ID = 2,Name = "lisi"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"}
};
return list;
}
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
var tmpList = GetStudentList();
var idList = (from item in tmpList select item.ID).ToList();
idList = new List<int>(idList.Distinct());
var tmp = gridView1.GetRowCellValue(e.RowHandle, "ID");
if (gridView1.GetRow(e.RowHandle) == null)
{
return;
}
for (int i = 0; i < idList.Count; i++)
{
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 1)
{
e.Appearance.BackColor = Color.Bisque;
}
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 2)
{
e.Appearance.BackColor = Color.CornflowerBlue;
}
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 3)
{
e.Appearance.BackColor = Color.SkyBlue;
}
}
}
{
get { return this.bindingSourceList.DataSource as BindingList<StudentDC>; }
set { bindingSourceList.DataSource = value; }
}
private void FrmGridTest_Load(object sender, System.EventArgs e)
{
StudentList = GetStudentList();
}
private BindingList<StudentDC> GetStudentList()
{
BindingList<StudentDC> list = new BindingList<StudentDC>(){
new StudentDC(){Class = "Class 1",ID = 1,Name = "zhangsan"},
new StudentDC(){Class = "Class 1",ID = 1,Name = "zhangsan"},
new StudentDC(){Class = "Class 2",ID = 2,Name = "lisi"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"},
new StudentDC(){Class = "Class 3",ID = 3,Name = "wangwu"}
};
return list;
}
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
var tmpList = GetStudentList();
var idList = (from item in tmpList select item.ID).ToList();
idList = new List<int>(idList.Distinct());
var tmp = gridView1.GetRowCellValue(e.RowHandle, "ID");
if (gridView1.GetRow(e.RowHandle) == null)
{
return;
}
for (int i = 0; i < idList.Count; i++)
{
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 1)
{
e.Appearance.BackColor = Color.Bisque;
}
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 2)
{
e.Appearance.BackColor = Color.CornflowerBlue;
}
if (Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ID")) == 3)
{
e.Appearance.BackColor = Color.SkyBlue;
}
}
}
相关文章推荐
- DEV GridControl绑定的数据,ID相同的行显示相同的颜色(当ID的值不确定时)
- DEV GridControl ID相同的行显示相同的颜色(当ID的值不确定时)
- C# dev GridControl绑定数据不能显示
- C# dev GridControl绑定数据不能显示
- Dev GridControl 有数据显示空行
- dev gridcontrol 绑定int型及日期型的列默认当值为0时显示空白及格式化日期显示方式
- DEV Gridcontrol 格式化显示数据
- Dev gridcontrol 对数据分组 ;0 1 2显示为 自定义字段
- DEV Gridcontrol 格式化显示数据
- dev Gridcontrol根据其cell里面的值显示不同颜色
- Dev GridControl控件绑定数据源,列不显示
- ExtJS gridPanel因数据字段id值相同而显示不全的解决方法
- dev gridcontrol选中多行数据
- dev gridcontrol (一)绑定值
- GridControl应用点滴之数据绑定
- [DevExpress]GridControl根据条件改变单元格/行颜色(Dev GridControl 单元格着色)
- 在Dev GridControl中添加颜色可变的ProgressBar z
- dev GridControl显示标题
- 数据绑定控件[选择类型控件]、图像显示控件【哈哈、28号就可以回家啦、亲们回家过中秋节啦~!各位们都淡定点啊~!】
- Devpress Gridcontrol中动态绑定数据库后如何设置列名