Hi,
In outlook, if a folder is empty, you get a message in the grid stating "There are no items to show in this view". I would like to do the same in my grids, but I can't find anything that seems like it would do the trick. Is this supported?
Thanks
Andy
Hi Andy,
This can be done using a CreationFilter. CreationFilters can be a bit daunting if you are not familiar with them, but this one would actually be pretty simple. The only question is, what part of the grid do you want to replace with this text? Do you want to replace the entire grid with just a label? Or do you want the column headers to still display?
I would like the column headers to still display, but not the row selectors or grid lines where the actual data would appear. Just like Outlook 2003 / 2007.
Okay, so in that case, you want to use the RowColRegionIntersectionUIElement. This is the element that contains the grid rows. What you would do is stop the grid from creating any child elements for this element and replace them with a TextUIelement with the text you want. The CreationFilter might look something like this:
public class NoItemsCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // Do nothing } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Is this a RowColRegionIntersectionUIElement if (parent is RowColRegionIntersectionUIElement) { // Get the grid (or Combo or DropDown) UltraGridBase grid = parent.Control as UltraGridBase; // Does the grid have no rows? if (grid.Rows.Count == 0) { // we should probably optimize this by searching through parent.ChildElements // to see if there is an existing TextUIElement we can use // instead of always creating a new one. TextUIElement textElement = new TextUIElement(parent, "There are no items to show in this view"); textElement.TextHAlign = HAlign.Center; textElement.TextVAlign = VAlign.Middle; textElement.Rect = parent.Rect; parent.ChildElements.Clear(); parent.ChildElements.Add(textElement); // Return true to cancel the normal creation of child elements. return true; } } // Return false, so the grid does the normal creation of child elements. return false; } #endregion }
For more information on CreationFilters, check out the Knowledge Base for samples and articles. Also, get the Infragistics UIElementViewer Utility.
Hello
This solution is what I am after, but when applied it still removes my column headers when do data is available, should it be applied to something other than grid.CreationFilter by chance?
Thank you,
Patrick
Hi Patrick,
I'm afraid I'm not following you. You want to display the message, but still show the column headers?
That would require a much more complex DrawFilter, since there is no single UIElement that contains the rows, but does not contain the Column Headers.