GridControl-Processbar 自定义颜色

本文介绍如何在BandedGridView中为特定列自定义进度条编辑器,通过比较目标值与实际值来改变进度条的颜色,适用于实时展示任务完成情况。
private void BandedGridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) {
	if (e.Column.FieldName == "TotalQtyProcess") {
		RepositoryItemProgressBar rp = new RepositoryItemProgressBar();

		rp.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
		rp.ShowTitle = true;
		//rp.PercentView = true;
		//rp.DisplayFormat.FormatType = FormatType.Numeric;
		//rp.DisplayFormat.FormatString = "n4";
		rp.Minimum = 0;

		object realCutNumObj = this.bandedGridView1.GetRowCellValue(e.RowHandle, bandedGridView1.Columns["RealCutNum"]);
		object totalQtyObj = this.bandedGridView1.GetRowCellValue(e.RowHandle, bandedGridView1.Columns["TotalQty"]);
		int realCutNum = realCutNumObj == DBNull.Value ? 0 : Convert.ToInt32(realCutNumObj);
		int totalQty = totalQtyObj == DBNull.Value ? 0 : Convert.ToInt32(totalQtyObj);

		rp.Maximum = realCutNum;
		if (totalQty > realCutNum) {
			rp.StartColor = Color.Red;
			rp.EndColor = Color.Red;
		}
		e.RepositoryItem = rp;
	} else if (e.Column.FieldName == "TodayQtyProcess") {
		RepositoryItemProgressBar rp = new RepositoryItemProgressBar();

		rp.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
		rp.ShowTitle = true;
		rp.Minimum = 0;

		object qtyTargetObj = this.bandedGridView1.GetRowCellValue(e.RowHandle, bandedGridView1.Columns["TodayQtyTarget"]);
		object todayQtyObj = this.bandedGridView1.GetRowCellValue(e.RowHandle, bandedGridView1.Columns["TodayQty"]);
		int qtyTarget = qtyTargetObj == DBNull.Value ? 0 : Convert.ToInt32(qtyTargetObj);
		int todayQty = todayQtyObj == DBNull.Value ? 0 : Convert.ToInt32(todayQtyObj);

		rp.Maximum = qtyTarget;
		if (todayQty > qtyTarget) {
			rp.StartColor = Color.Green;
			rp.EndColor = Color.Green;
		}
		e.RepositoryItem = rp;
	}
}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值