dev treelist 中 repositoryItemProgressBar1如何更变颜色

小白养大牛 2017-11-06 02:34:59


如何更改完成度这列的进度条颜色,我想小于50%的变红色。不想用treeList1_CustomDrawNodeCell事件画出来,这列的ColumnEdit 是 repositoryItemProgressBar1,如何更改repositoryItemProgressBar1的颜色。我现在用这种会一直在里面遍历,导致卡死在界面,求大神解惑
private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
{
if (e.Column.FieldName == "FCompletion")
{

repositoryItemProgressBar1.LookAndFeel.UseDefaultLookAndFeel = false;
decimal percent = Convert.ToDecimal(e.CellValue);
if (percent < 50)
{
repositoryItemProgressBar1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
}
else
{
repositoryItemProgressBar1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Office2003;
}
}
}
...全文
489 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
小白养大牛 2017-11-10
  • 打赏
  • 举报
回复
引用 1 楼 duanzi_peng 的回复:
自己上官网搜用法吧,这里几乎没人用过。https://documentation.devexpress.com/WindowsForms/7874/WinForms-Controls
好像真的不能修改一列不同颜色显示,画上去的效果没有repositoryItemProgressBar1这个控件的效果好看,所以我就放弃了。。不过还是放上来吧 private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.FieldName == "完成度") { decimal percent = Convert.ToDecimal(e.CellValue); int width= (int)(10*Math.Abs(percent) * e.Bounds.Width / 100); Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, width, e.Bounds.Height); Brush b = Brushes.Green; if (percent < 50) b = Brushes.Red; else b = Brushes.Green; e.Graphics.FillRectangle(b, rect); } }
小白养大牛 2017-11-06
  • 打赏
  • 举报
回复
引用 3 楼 yuyanxing09 的回复:
我原来在web上做的,用2张图片代替的。百分比就把图片长度按百分比写了。
额。。我现在就知道怎样改颜色
耗子哭死猫 2017-11-06
  • 打赏
  • 举报
回复
我原来在web上做的,用2张图片代替的。百分比就把图片长度按百分比写了。
小白养大牛 2017-11-06
  • 打赏
  • 举报
回复
@duanzi_peng 那请问能否直接遍历该列的所有值?那如何去遍历列的所有值呢
exception92 2017-11-06
  • 打赏
  • 举报
回复
自己上官网搜用法吧,这里几乎没人用过。https://documentation.devexpress.com/WindowsForms/7874/WinForms-Controls

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧