DevExpress.XtraGrid.view.gridview toolTipController

为gridView添加toolTip,

toolTipController1_GetActiveObjectInfo事件
   private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            GridControl gc = e.SelectedControl as GridControl;
            if (gc == null) return;
            ToolTipControlInfo info = null;
            try
            {
                GridView view = gc.GetViewAt(e.ControlMousePosition) as GridView;
                if (view == null) return;
                GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
                if (hi.InRowCell)
                {
                    info = new ToolTipControlInfo(new CellToolTipInfo(hi.RowHandle, hi.Column, "cell"), GetCellHintText(view, hi.RowHandle, hi.Column));
                    return;
                }

                if (hi.HitTest == GridHitTest.RowIndicator)
                {
                    info = new ToolTipControlInfo(GridHitTest.RowIndicator.ToString() + hi.RowHandle.ToString(), "Row Handle: " + hi.RowHandle.ToString());
                    return;
                }

            }
            catch (Exception ex)
            {
            }
            finally
            {
                e.Info = info;
            }
        }
GetCellHintText 自定义函数
private string GetCellHintText(GridView view, int rowHandle, GridColumn gridColumn)
        {
            string displaytext = view.GetRowCellDisplayText(rowHandle, gridColumn);
            if (gridColumn.FieldName == "CFAMILYID")
            {
                displaytext = "家庭编号";
            }
            return displaytext;
        }

示例图:

posted @ 2013-01-30 14:45  石 磊  阅读(1752)  评论(0编辑  收藏  举报