GridControl 行数据信息显示功能
using DevExpress.Utils;using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
先添加一个ToolTipController控件在GetActiveObjectInfo事件里
private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
{
if (e.SelectedControl == this.gridControl1)
{
ToolTipControlInfo toolTipControlInfo = null;
GridView gridView = this.gridControl1.GetViewAt(e.ControlMousePosition) as GridView;
if (gridView != null)
{
GridHitInfo gridHitInfo = gridView.CalcHitInfo(e.ControlMousePosition);
if (gridHitInfo.HitTest == GridHitTest.RowIndicator)
{
object @object = gridHitInfo.HitTest.ToString() + gridHitInfo.RowHandle.ToString();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("行数据基本信息:");
foreach (GridColumn gridColumn in gridView.Columns)
{
if (gridColumn.Visible)
{
stringBuilder.AppendFormat(" {0}:{1}\r\n", gridColumn.Caption, gridView.GetRowCellDisplayText(gridHitInfo.RowHandle, gridColumn.FieldName));
}
}
toolTipControlInfo = new ToolTipControlInfo(@object, stringBuilder.ToString());
}
if (toolTipControlInfo != null)
{
e.Info = toolTipControlInfo;
}
}
}
}
页:
[1]