Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2060
Bind a Tool Tip
posted

Hi,

I found a few threads on the subject of tool tips with the same end result I'm trying to achieve but they were from a couple of years ago, so I thought I'd ask a similar question in case things have changed......

We have a cell that will display a warning icon (Field Name: HasWarning). When the user hovers over the icon/cell we'd like the reason for the warning (Field Name: WarningMessage) to appear as a tool tip.  i.e. the tool tip is populated from another field in the datasource.  

The warning message wasn't required originally so to avoid using the Initialize_Row to populate the cell with an icon we were using a value list for the HasWarning (boolean) field.  The values list contained "True, <Icon>" and "False, Null".

Since then our client has asked for the reason to appear as a tool tip.  Can you bind the tool tip text to a field on the datasource or will we have to code it using the Initialize_Row event?

i.e.  pseudo code

private sub Grid_Initialize_Row()

if row.HasWarning = true then

row.HasWarning.ToolTip = row.ListObject.WarningMessage

End if

Kind regards,

Nathan

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi Nathan,

    Yes, you can do this very easily using a DataError. The grid has support for displaying errors in the data source that are exposed via the IDataError interface. So if you are using a DataTable, you could apply an error to a field and the grid would display an error icon and also show a tooltip with the error text.

    In v13.1, we added the ability to apply errors directly to the grid, instead of the data source.

    Here's some quick sample code that shows you how to do it:


            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                UltraGridLayout layout = e.Layout;
                UltraGridOverride ov = layout.Override;

                ov.SupportDataErrorInfo = SupportDataErrorInfo.RowsAndCells;
                ov.DataErrorCellAppearance.Image = myImage;
            }
          
            private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
            {
                if ((int)e.Row.Cells["Int32 1"].Value < 5)
                {
                    e.Row.DataErrorInfo.SetColumnError("Int32 1", "The value in this cell must be 5 or more");                
                }
            }

Reply Children