程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> 關於.NET >> DevExpress ToolTipController實現工具提示控件,devexpress控件

DevExpress ToolTipController實現工具提示控件,devexpress控件

編輯:關於.NET

DevExpress ToolTipController實現工具提示控件,devexpress控件


1.定義一個ToolTipController變量   private ToolTipController _mToolTipController = null;

2.封裝在一個方法中

protected void ToolTipController(GridControl gcData)
{
if (_mToolTipController == null)
{
_mToolTipController = new ToolTipController();
}
if (_mToolTipController == null) return;
if (gcData != null)
gcData.ToolTipController = _mToolTipController;
_mToolTipController.GetActiveObjectInfo += toolTipController_GetActiveObjectInfo;//綁定一個事件
}

//事件方法

private void toolTipController_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)
{
WriteExceptionLog(ex);
}
finally
{
if (info != null) e.Info = info;
}
}

//提示信息

private string GetCellHintText(GridView view, int rowHandle, GridColumn gridColumn)
{
string displaytext = view.GetRowCellDisplayText(rowHandle, gridColumn);
displaytext = "提示信息";
return displaytext;
}

3.調用

ToolTipController(gcData);//gcData為列表控件

鼠標移動到每個單元格都會出現提示:

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved