2024年终活动

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

XtraGrid控件如何动态自定义控制按钮的显示

来源:本站原创   发布时间:2012-12-25   浏览:3400次

解决方法:

请参考以下代码:

private void gvTimeGroup_CustomDrawCell(object sender,
DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
         {
             if (e.Column.FieldName == "IsFinished")
             {
                 DevExpress.XtraEditors.ViewInfo.ButtonEditViewInfo buttonEditViewInfo =

(DevExpress.XtraEditors.ViewInfo.ButtonEditViewInfo)

((DevExpress.XtraGrid.Views.Grid.ViewInfo.GridCellInfo)e.Cell).ViewInfo;
 
                if (e.CellValue.Equals("1"))//判断条件,具体情况另行修改
                 {
                     buttonEditViewInfo.RightButtons[0].Button.Enabled = false;//必须有,否则即

使button状态为灰色,但点击还会触发事件
                     buttonEditViewInfo.RightButtons[0].State =

DevExpress.Utils.Drawing.ObjectState.Disabled;
                 }
                 else
                 {
                     buttonEditViewInfo.RightButtons[0].Button.Enabled = true;
                     buttonEditViewInfo.RightButtons[0].State =

DevExpress.Utils.Drawing.ObjectState.Normal;
                 }
             }
         }

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/447.html
扫码咨询
电话咨询
023-68661681
返回
顶部