鼠标指向表格时 显示更多信息 toolTipController1

//窗体添加 控件 ,然后将GridControl 相关属性栏对应上新加的控件 切记  本文是转帖,稍作修改    
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e) { this.gridControl1.ToolTipController = tip; if (e.SelectedControl != gridControl1) return; ToolTipControlInfo info = null; GridView view = gridControl1.GetViewAt(e.ControlMousePosition) as GridView; if (view == null) return; GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition); //if (hi.HitTest == GridHitTest.RowIndicator)// 我测试时要注掉这行才搞定 //{ //An object that uniquely identifies a row indicator cell object o = hi.HitTest.ToString() + hi.RowHandle.ToString(); StringBuilder sb = new StringBuilder(); sb.AppendLine("更多信息:"); foreach (GridColumn gridCol in view.Columns) { if (!gridCol.Visible)//如果加 ! 表示 被隐藏的列,如果不加,则显示所见的列 { sb.AppendFormat(" {0}:{1}\r\n", gridCol.Caption, view.GetRowCellDisplayText (hi.RowHandle, gridCol.FieldName)); } } info = new ToolTipControlInfo(o, sb.ToString()); // } //Supply tooltip information if applicable, otherwise preserve default tooltip (if any) if (info != null) { e.Info = info; } }
原文地址:https://www.cnblogs.com/bantongshui/p/3170015.html