怎样在DevExpress XtraTreeList中设置ToolTip?
您可以使用ToolTipController控件,然后通过ToolTipController.GetActiveObjectInfo事件来设置ToolTip
关键代码:
private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
{
if (e.SelectedControl is DevExpress.XtraTreeList.TreeList)
{
TreeList tree = (TreeList)e.SelectedControl;
TreeListHitInfo hit = tree.CalcHitInfo(e.ControlMousePosition);
if (hit.HitInfoType == HitInfoType.Cell)
{
object cellInfo = new TreeListCellToolTipInfo(hit.Node, hit.Column, null);
string toolTip = string.Format("{0} (Column: {1}, Node ID: {2})", hit.Node[hit.Column],
hit.Column.VisibleIndex, hit.Node.Id);
e.Info = new DevExpress.Utils.ToolTipControlInfo(cellInfo, toolTip);
}
}
}
参考:http://www.devexpresscn.com/DevExpress-Resources/Demo-38.html