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 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.
Hi
It looks like the answer is to implement the AfterCreateChildElements method instead, this appears to be working now, is this the best solution?
Patrick
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,
Thanks, I'll check this out!
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.