RadScrollablePanel - Set Scroll for a specific object to be at top of panel

1 Answer 90 Views
ColorDialog ScrollBar
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 31 May 2023, 08:03 PM

I have many Collapsible Panels in my Scrollable Panel, what I need it to do, is if the user expands a panel, I need that panel to scroll to the top of the scrollable panel.   Is there a way to pragmatically do this?

 

TIA.

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 05 Jun 2023, 09:55 AM

Hello,

Following the provided information, I have prepared a sample project to get better understanding of the precise case. The RadScrollablePanel.VerticalScrollbar.Maximum property gives you information about the current range for the vertical scrollbar according to the size of the panel.

If the RadScrollablePanel.AllowAutomaticScrollToControl property is enabled, this means that the view will be scrolled to the currently active control. Hence, in order to scroll to a specific control, you just need to focus it:

        public RadForm1()
        {
            InitializeComponent();

            this.radScrollablePanel1.AllowAutomaticScrollToControl = true; 
        } 

        int cnt = 0;

        private void radButton1_Click(object sender, EventArgs e)
        {
            this.ActiveControl = this.radScrollablePanel1.PanelContainer.Controls[cnt]; 
            cnt++;
            if (cnt >= this.radScrollablePanel1.PanelContainer.Controls.Count)
            {
                cnt = 0;
            }
        }

Note that this is just a sample approach and it may not cover all possible cases. Feel free to further extend it and modify it in a way which suits your requirements best.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
commented on 05 Jun 2023, 11:10 AM

Thanks, we have the property set.  We are also setting focus to that control as well, but we had cases, where some of our Collapsible Panels would not be completely show and the user would have to scroll down still. What we did was implemented a hidden control, at the bottom of the last Collapsible Panel, and every time one of our panels are Expanded and/or focused, we set focus to that control first, then we set focus back to the original panel. This achieves the following.  1. Shows the entire panel in the scrollable panel and 2, for all the panels except the last few, the panel is always at the top of the scrollable panel (which is the desired affect). We do have issues with the last few panels not pushing to the top of the scrollable panel (but they show the entire panel), but I think we understand way.

 

Thanks for the help on this. 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 06 Jun 2023, 01:15 PM

Hi, Mark,

It sounds like you succeeded to observe the required custom behavior. Focusing the hidden control just below the collapsible panel is a valid approach and you can use it for your needs. Should you have further questions please let me know.

Tags
ColorDialog ScrollBar
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or