Using the code in the sample "WinToolTipManager - Tool Tips with Context" I am able to create a balloon ToolTip for a UltraGridCell by using the SetColumnError method:
row.SetColumnError("ColumnKey","Tool tip message."
This works quite well (though somewhat cumbersome using the helpers classes) provided the underlying data source is a datatable.
How can I achieve this same functionality when the data source is an IbindingList? Since the list doesn't have rows (only a collection of entities), there is no SetColumnError method.
Hello Jake,
if I understand well your requirement, I think that you could use this sample to create a ToolTip regardless of your DataSource. The mentioned method - SetColumnError() is used in this sample to show small red Attention image in the decimal cells where the value is negative. Please take a look at the attached video file for more details.
Please let me know if you think that I misunderstand your request or if you have any further questions.
Regards
Hi Georgi,
Thank you for your reply! The video you sent is defective - when I try to extract it I get the message "CRC failed. File is broken."
I can create a standard Microsoft ToolTip (text) and attach it to any cell in an UltraGrid. I am trying to use Infragistics' UltraToolTipInfo and attach it to a specif cell, or even a infragisitics.win.tooltip. I can attach them to the entire grid, but can't seem to figure out how to attach them to an individual cell.
Hi Mike,
Thanks again for your advice!
Yes, it does seem that the error is tied not to the data element, but rather to the DataRow object and that the display of the grid cell's error icon takes its ques from the DataRow not the DataRow's listobject nor some setting in the grid's cell.
I don't need an additional column because the CodeFluent entity itself has a column, System_ComponentModel_IDataErrorInfo_Error, that shows up in the UltraGrid when the grid's data source is a CodeFluent EntityCollection. I can hide that column and use that column's contents to trigger the display of an UltraToolTipInfo object. There is a bit of programming needed to show/hide the error icon as well as displaying the error ToolTip for both the cell and the row. I would be nice to have all that taken care of by the grid regardless of the grid's data source..
Thank you again for your assistance in this matter.
-J
Hi,
Jake K said:But since myEntity is not a DataRow and not part of a DataTable I have no way of programmatically setting the error.
Okay. The DataRow itself exposes methods to allow you to set the error via the SetColumnError method. If the EntityFramework does not provide a similar method, then I'm afraid that's not something I can advise you on. As I said, I'm not an expert on the Entityframework. If you need help there, you will need to seek assistance from Microsoft, I think.
Or... like I said, you could simply store the error in a hidden column in the grid and show an image in the cell using the cell's appearance, bypassing the IDataErrorInfo entirely. :)
I get that UltraToolTipManager with Context demonstrates how to show a tooltip for any particular UIElement in the grid. The sample shows how to use UltraToolTipManager when the cell has an associated error. Setting the error has become the problem. I've done it too many times to count, but in those cases I had a dataset / datatable / datarows / datacells. I never really gave it much thought and figured setting the DataErrorInfo by using the SetColumnError method took care of flagging a cell with the error icon.
The CodeFluent entity has a column, System_ComponentModel_IDataErrorInfo_Error, that gets set when the Validate method for the entity is called. For example:
private void UltraGrid1_AfterCellUpdate(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e){ myNamespace.myEntity _myEntity = default(myNamespace.myEntity); _myEntity = (myNamespace.myEntity)e.Cell.Row.ListObject; string _errors = _myEntity.Validate(System.Globalization.CultureInfo.CurrentCulture); string _errorMessage = _myEntity.System_ComponentModel_IDataErrorInfo_Error; dynamic _errorElement = _myEntity.System_ComponentModel_IDataErrorInfo_Item(e.Cell.Column.Key);}
But since myEntity is not a DataRow and not part of a DataTable I have no way of programmatically setting the error. I thought having IDataErrorInfo set triggered the display of the underlying cell's error icon. Following the sample, UltraToolTipManager with Context, I simply thought I could use SetColumnError and that is when the I discovered I could not use SetColumnError because the underlying ListObject was not a DataCell in a DataRow. For example, the following code fails on line 2 on the cast conversion.
{string ErrorMessage = _designation.Validate(System.Globalization.CultureInfo.CurrentCulture);DataRowView drv = (DataRowView)e.Row.ListObject; drv.Row.RowError = rowError; drv.Row.SetColumnError(e.Cell.Column.key, ErrorMessage);}
The solution seems to be a variant of the System_ComponentModel_IDataErrorInfo_Error sample. In the PrepareGridToolTipHelper method PrepareToolTip check for contents in the CodeFluent entity's System_ComponentModel_IDataErrorInfo_Item(e.Cell.Column.Key) during the MouseOver event and display the error as the ToolTip. Also, the cell's error icon has to be set and reset programmatically. This seems convoluted, but I can probably write the logic as an extention to the grid until Microsoft and Infragistics comes up with a cleaner / easier way of setting a cell error for non DataRow entities.
UltraToolTipManager with Context
I'm still confused about where you are having trouble.
UltraToolTipManager with Context demonstrates how to show a tooltip for any particular UIElement in the grid. So that doesn't really have anything to do with a DataRow. The DataRow is irrelevant.
There are two issues here:
1) How to store the error on the row.
2) How to display the tooltip.
For part 1, you have two options. You can either use IDataErrorInfo or you can store the error yourself. If you want to use IDataErrorInfo, then you don't necessarily need a DataRow, all you need is a class that implements IDataErrorInfo. To set the error on the row, you get the ListObject from the grid row and aply the error to it. In the case of a DataRow, the row itself provides you with a way to apply an error (the SetError method if memory serves). If the objects you are using don't give you any methods for this, then that's something you would need to work out with Microsoft - I don't know enough about the EntityFramework to tell you how to apply an error to an item.
Part 2 is trickier. If you use IDataErrorInfo to provide the errors and thus the images in the grid, then the grid provides the tooltips for you. There's no way to hook up an UltraToolTipManager. You might be able to get the ToolTipInfo and modify the tooltips a little but, but I'm not entirely sure if it's possible or exactly what you want to do to the tooltip. I also don't see any way to turn off the built-in tooltips so that you could then use the UltraToolTipManager With Context to provide your own.
So perhaps the easiest solution for you would be to use an unbound column to store the error information, place an image in the cell via the appearance (you can use the same Appearance you are already using to make the cell yellow) and use the UltraToolTipManager With Context technique to provide the tooltip for the image.
Thank you for your reply. The collection, which is a CodeFluent entity collection, does in-fact implement IDateErrorInfo.
The entity implements:
System.ICloneable, System.IComparable, System.IComparable(Of myEntity), CodeFluent.Runtime.ICodeFluentCollectionEntity(Of System.Guid), System.ComponentModel.IDataErrorInfo, CodeFluent.Runtime.ICodeFluentMemberValidator, CodeFluent.Runtime.ICodeFluentSummaryValidator, System.IEquatable(Of myEntity)
The entity collection implements:
System.Collections.IList, System.Collections.ICollection, CodeFluent.Runtime.ICodeFluentSet, System.Collections.Generic.IList(Of myEntity), System.Collections.Generic.ICollection(Of myEntity), System.ComponentModel.IRaiseItemChangedEvents, System.ICloneable, System.ComponentModel.INotifyPropertyChanged, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.IBindingList, System.ComponentModel.ICancelAddNew
In my application, the grid is large and a bit complicated - but the user loves it - especially since I have things pop out into card view. The biggest complaint I am receiving is that when I set a cell's tootip.text to an error message, the user doesn't always see them (even though I change the cell's background color to yellow) and that the message is too small and doesn't appear long enough to be read. So naturally, I thought UltraToolTip - big, colorful, balloon, controlled timing. Then I found the sample UltraToolTipManager with Context and thought "perfect!" I just couldn't figure out how to use it without a DataRow.