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
530
How to see if scrollbar is visible of UltraformattedTextbox
posted

Hi,

I would like to see if horizontal scrollbar is visible in a ultraformattedtextbox and what heigth it has? How can I do this?

Thanks

Emil

  • 469350
    Verified Answer
    Offline posted

    Hi Emil,

     

    ScrollBar height is a system setting, so you can get the height from the SystemInformation class:

    SystemInformation.HorizontalScrollBarHeight

     

    As to whether or not the horizontal scrollbar is visible, as long as the FormattedTextEditor is visible and has painted at least once, you could get this using the UIElements:


            private bool HasHorizontalScrollBar(UltraFormattedTextEditor ultraFormattedTextEditor)
            {
                ScrollableAreaUIElement scrollableAreaUIElement = ultraFormattedTextEditor.UIElement.GetDescendant(typeof(ScrollableAreaUIElement)) as ScrollableAreaUIElement;
                if (scrollableAreaUIElement != null)
                {
                    foreach(UIElement element in scrollableAreaUIElement.ChildElements)
                    {
                        ScrollBarUIElement scrollBarUIElement = element as ScrollBarUIElement;
                        if (scrollBarUIElement != null)
                        {
                            if (scrollBarUIElement.Orientation == Orientation.Horizontal)
                            {
                                return true;
                            }
                        }
                    }
                }

                return false;
            }