DevExpress GridControl 行头显示行信息

使用DevExpress GridControl控件时经常用的方法 


//扩展

public static class tool
{
<span style="white-space:pre">	</span>/// <summary>
        /// 设置行头显示行数据信息
        /// </summary>
        public static DevExpress.XtraGrid.GridControl ExecuteSetRowHandShowInfo(this  DevExpress.XtraGrid.GridControl _GridControl) 
        {
            DevExpress.XtraGrid.Views.Grid.GridView _GridView=(DevExpress.XtraGrid.Views.Grid.GridView)_GridControl.MainView;
            System.ComponentModel.IContainer components  = new System.ComponentModel.Container();
            DevExpress.Utils.ToolTipController toolTipControlInfo2 =  new DevExpress.Utils.ToolTipController(components);
            toolTipControlInfo2.GetActiveObjectInfo += new DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventHandler(delegate(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
            {
                try
                {
                    ToolTipControlInfo toolTipControlInfo = null;
                    if (_GridView == null)
                        return;

                    var gridHitInfo = _GridView.CalcHitInfo(e.ControlMousePosition);
                    if (gridHitInfo.HitTest == GridHitTest.RowIndicator)
                    {
                        if (int.Parse(gridHitInfo.RowHandle.ToString()) < 0)
                        {
                            return;
                        }
                        object obj = gridHitInfo.HitTest + gridHitInfo.RowHandle.ToString();

                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("基本信息:\r\n");
                        foreach (GridColumn gridColumnInfo in _GridView.Columns)
                        {
                            if (gridColumnInfo.Visible)
                            {
                                stringBuilder.AppendFormat("      {0}:{1}\r\n",
                                    gridColumnInfo.Caption.Equals("") ? gridColumnInfo.FieldName : gridColumnInfo.Caption,
                                    _GridView.GetRowCellDisplayText(gridHitInfo.RowHandle, gridColumnInfo.FieldName));
                            }
                        }
                        toolTipControlInfo = new ToolTipControlInfo(obj, stringBuilder.ToString());
                    }

                    if (toolTipControlInfo != null)
                    {
                        e.Info = toolTipControlInfo;
                    }
                }
                catch (Exception ex)
                {

                }

                });
            _GridControl.ToolTipController = toolTipControlInfo2;
            return _GridControl;
        }
}


//调用  
  this.NotChineseDrugControl.ExecuteSetRowHandShowInfo();


  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值