Kliver Max
Kliver Max

Reputation: 5299

How to show tool tip in GridLookUpEdit?

I have a GridLookUpEdit controller and ToolTipController and want to show tooltips for GridLookUpEdit's rows on FocusedRowChanged event.
But i cant find any examples.
Im already tried:

toolTipController1.SetToolTip(MyGridLookUpEdit, "Test");

But tooltip not shown.

private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
    {
      ToolTipControlInfo info = null;
      GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
      object o = hi.HitTest.ToString() + hi.RowHandle.ToString();
      string text = "Row " + hi.RowHandle.ToString();
      info = new ToolTipControlInfo(o, text);
      if (info != null)
        e.Info = info;
    }

Same result.
What can be wrong?

Upvotes: 0

Views: 1044

Answers (2)

nempoBu4
nempoBu4

Reputation: 6631

You need to attach your ToolTipController to underlying GridControl of your GridLookUpEdit:

gridLookUpEdit1.Properties.View.GridControl.ToolTipController = toolTipController1;

Then you can use ToolTipController.GetActiveObjectInfo event to show the tooltip. To get the focused value you can use ColumnView.GetFocusedRowCellValue method or GridView.GetFocusedValue method.
Here is example:

private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
{
    var gridControl = gridLookUpEdit1.Properties.View.GridControl;

    if (e.SelectedControl == gridControl)
    {
        var view = gridControl.GetViewAt(e.ControlMousePosition) as GridView;

        if (view != null)
        {
            object focusedValue = view.GetFocusedRowCellValue(view.Columns[0]);

            if (focusedValue != null)
                e.Info = new ToolTipControlInfo(view.FocusedRowHandle, focusedValue.ToString());
        }
    }
}

Upvotes: 2

Zer0
Zer0

Reputation: 7354

First make sure you've attached the controller

MyGridLookUpEdit.ToolTipController = toolTipController1;

Then try this

private void toolTipController1_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
{
  GridHitInfo hi = view.CalcHitInfo(e.ControlMousePosition);
  if (hi.InRowCell)
  {
    string text = "Row " + hi.RowHandle.ToString();
    e.Info = new ToolTipControlInfo(hi.RowHandle, text);
  }
}

Upvotes: 1

Related Questions