一、UltraGrid更换行背景色
private void dxGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e)
{
foreach (UltraGridRow row in this.dxGrid.Rows)
{
if (row.Cells["IsAllowEdit"].Value.ToString() == "True")
{
row.Appearance.BackColor = Color.LightBlue;
}
if (row.Cells["ConfirmPayApproveID"].Value.ToString() == "3")
{
row.Appearance.BackColor = Color.LightGreen;
}
}
}
二、UltraGrid多表头代码设置
DateTime currentDateTime=base.GetServerTime(); //当前时间
DateTime currentStartMonth = currentDateTime.AddDays(1 - currentDateTime.Day); //本月月初
DateTime lastStartMonth1 = currentStartMonth.AddMonths(-3); //前三月月初
DateTime lastStartMonth2 = currentStartMonth.AddMonths(-2); //前二月月初
DateTime lastStartMonth3 = currentStartMonth.AddMonths(-1); //前一月月初
this.dxGrid.DisplayLayout.Bands[0].Columns["自驾"].RowLayoutColumnInfo.LabelPosition = LabelPosition.LabelOnly;
this.dxGrid.DisplayLayout.Bands[0].Columns["代驾"].RowLayoutColumnInfo.LabelPosition = LabelPosition.LabelOnly;
this.dxGrid.DisplayLayout.Bands[0].Columns["SelfDriveFisrtMonthAMount"].Header.Caption =lastStartMonth1.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["SelfDriveSecondMonthAMount"].Header.Caption = lastStartMonth2.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["SelfDriveThirdMonthAMount"].Header.Caption = lastStartMonth3.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["SelfDriveAllMonthAMount"].Header.Caption = "合计";
this.dxGrid.DisplayLayout.Bands[0].Columns["ChauffeurDirveFisrtMonthAMount"].Header.Caption = lastStartMonth1.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["ChauffeurDirveSecondMonthAMount"].Header.Caption = lastStartMonth2.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["ChauffeurDirveThirdMonthAMount"].Header.Caption = lastStartMonth3.ToString("yyyy年MM月");
this.dxGrid.DisplayLayout.Bands[0].Columns["ChauffeurDirveAllMonthAMount"].Header.Caption = "合计";
for (int i = 0; i < this.dxGrid.DisplayLayout.Bands[0].Columns.Count; i++)
{
this.dxGrid.DisplayLayout.Bands[0].Columns[i].Header.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
this.dxGrid.DisplayLayout.Bands[0].Columns[i].Header.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
}