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
25
UltraWinGrid last visible row
posted

Hi and thanks for reading my question,

I have a UltraWinGrid with a large number of rows, let's say more than 100.  On the screen at a given time there are visible only about 7, 8 of them. I'm looking for a way of showing only the rows that are fully visible, so if the last row is not completely visible it should not be visible until the grid is scrolled. 

I've searched for a property or for a method of doing this. It can easily be done for columns but i haven't found a way to do it for rows. Also in this case resizing the grid is not an option.

Thanks for any tips,

Adrian Faciu.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Adrian,

    So basically, you don't want the grid to show any partially-visible rows?

    You would have to use a CreationFilter for this. Here's some quick code I whipped up which seems to work pretty well:


            public class HidePartialRows_CreationFilter : IUIElementCreationFilter
            {
                #region IUIElementCreationFilter Members

                void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
                {
                    // Check for the RowColRegionIntersectionUIElement. This is the element
                    // that contains the RowUIElements (and possibly other things).
                    if (parent is RowColRegionIntersectionUIElement)
                    {
                        // Keep a list of elements that we want to remove. We will probably
                        // only have one element in the list, but it doesn't hurt to be extra careful.
                        List<UIElement> elementsToRemove = new List<UIElement>();

                        // Loop through the child elements.
                        foreach (UIElement element in parent.ChildElements)
                        {
                            // Check for RowUIElements. We don't care about any other type here,
                            // so if it's not a RowUIElement, skip it.
                            RowUIElement rowUIElement = element as RowUIElement;
                            if (rowUIElement == null)
                                continue;

                            // Check to see if the RowUIElement extends beyond the bottom of the parent.
                            if (rowUIElement.Rect.Bottom > parent.Rect.Bottom)
                            {
                                // This Row is clipped, so add it to the list of elements to remove.
                                // We don't want to remove the element here directly, because that
                                // would modify the contents of the ChildElements collection, and we
                                // are currently in a ForEach loop on that collection so it's a bad idea.
                                elementsToRemove.Add(element);                           
                            }
                        }

                        // Remove all of the elements we marked for removal.
                        foreach (UIElement element in elementsToRemove)
                        {
                            parent.ChildElements.Remove(element);
                        }
                    }               
                }

                // Do nothing
                bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
                {
                    return false;
                }

                #endregion
            }

Children