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
Excellent, thanks Mike.
The cell will only display one error.
If your data source returns an error for a cell via the IDataErrorInfo and then you set an error on the same cell via the grid, the grid error will take precedence and only the grid error will display.
But if your data source returns an error for one cell and you apply an error the grid in a different cell, then they will both display (in their respective cells).
Cheers Mike, that would work.
Now you can apply errors directly to the grid, does this mean you could have datasource errors and your own?
For example we use IDataError for reporting validation errors on the datasource. Could you apply errors direct to the grid and in conjunction with the datasource errors?
i.e. An Error comes from the editable business class, but we could create warnings and information types with different icons direct to the grid?
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"); } }