views:

826

answers:

2

I'm trying to show a windows forms tooltip inside a datagrid to highlight an error. The problem I have is that everytime I call tooltip.Show("You have an error", datagrid, 0, 0), The tooltip is confined within the datagrids boundaries and doesn't go outside, which ultimately means the tooltip itself covers up the actual row where the error occurs.

I thought about tooltip.Show("You have an error", Form1, ?, ?) but I don't see an easy way to compute the offset of the datagrid on the form. Since all controls are docked, depending on how the user resizes the form, the location will change.

There is a caveat, the datagrid itself is not a Forms.DataGrid, instead it is an Infragistics UltraGrid which may do funny things itself, which are outside of my ability to alter.

A: 

Have you looked at these:

HOWTO:Create Advanced ToolTips For The WinGrid

BeforeDisplayDataErrorTooltip Event

Mitch Wheat
I have looked at those now, but I am using `tooltip.Show` to have a popup balloon box which cannot be dismissed easily (because the input is in error). At the same time, I do not want it to interfere with input.
hova
A: 

It turns out that it's easy enough to get the location for the Show command from the UltraGrid by querying the UIElement associated with it. Here's what I'm doing:

private void ultraGrid1_BeforeCellUpdate(object sender, BeforeCellUpdateEventArgs e)
{
    if (!DataFormat.CanEdit(e.Cell.Row.ListObject, e.Cell.Column.PropertyDescriptor))
    {  
        var tip = new System.Windows.Forms.ToolTip();
        tip.BackColor = Color.Orange;
        tip.Show("unable to edit", this, e.Cell.GetUIElement().Rect.Left, e.Cell.GetUIElement().Rect.Top, 500);
        e.Cancel = true;
    }
}
Rob Archibald