I have a XtraScrollableControl, onto which I have added a FlowLayoutPanel, set with DockStyle.Fill. I have several chart controls on the FlowLayoutPanel. When the main form is stretched and resized the various panels appear. When the form is too small to show all the charts, I do no get a scrollbar.
I do get a scrollbar when I set AutoScroll = true on the FlowLayoutPanel. However, I do not want to use the scrollbar of the FlowLayoutPanel, as this does not match the way the the scrollbars are painted on other DevExpress controls (based on current/default skin).
How can I get the XtraScrollbarControl's scrollbar to show in my attached sample project, so that I can get the scrollbar using the correct skin?
Thanks, Elan
Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.
Hi Elan,
The XtraScrollableControl doesn't show scrollbars, because the control within it is docked with the "Fill" style. When the control is docked this way, it will be resized along with its parent, so when you resize the XtraScrollableControl, the docked FlowLayoutPanel is resized too, its size doesn't exceed the size of the XtraScrollableControl and the scrollbar doesn't appear. In this case, you should use the XtraScrollableControl's AutoScrollMinSize property. This property is the XtraScrollableControl's size when it shows scrollbars regardless of the dock style set for its child controls.
Thanks,
Ted
Hi Ted,
Thanks for your information. This helped me come up with a solution. The XtraScrollableControl's vertical scrollbar now appears automatically and only when needed. Here is how I solved this:
I have a XtraScrollableControl which is docked to "Fill" to its parent control on the form, so that the XtraScrollableControl is resized when the form is resized. I placed the FlowLayoutPanel on an XtraScrollableControl. I set the dock style to "None" on the FlowLayoutPanel, and set its anchor property to "Top, Left, Right". I then implemented an event handler for the XtraScrollableControl Resize event, in which I manually set the size of the FlowLayoutPanel to exceed the size of its parent control as follows:
private void xtraScrollableControl_Resize(object sender, EventArgs e)
{
int height = 0;
foreach (Control control in this.flowLayoutPanel.Controls)
{
if (control.Location.Y + control.Size.Height > height)
{
height = control.Location.Y + control.Size.Height;
}
}
height += this.flowLayoutPanel.Padding.Bottom;
int width = this.xtraScrollableControl.Width - SystemInformation.VerticalScrollBarWidth;
this.flowLayoutPanel.Size = new Size(width, height);
}
I was interested in having a vertical scrollbar only and the above automatically displays the DevExpress vertical scrollbar when needed.
Hi Elan, I'm happy to hear that the problem is now resolved. Thank you for informing us of that.
Thanks,
Ted
This is simplified even further as follows:
Setting the anchor on FlowLayoutPanel to Top, Left, Right combined with setting AutoResize = true is all that is needed. There is no need to handle the Resize event. The vertical scrollbar automatically appears as needed when the form is resized.
Elan
Correction: Property is AutoSize = true on FlowLayoutPanel.
OK, Elan. I'm glad to hear that you managed to find a more simple solution.
Thanks,
Ted
How to make an XtraScrollableControl to have the skin of the layout? Changing BackColor property to Transparent doesn't help.
Hello,
I've created a separate ticket on your behalf (T873373: XtraScrollableControl - How to use the layout skin). It has been placed in our processing queue and will be answered shortly.