What is the recommended way to place a RadElement instance on a Form?
Below is code from my form constructor. My goal is that the form would show a scrollbar if sized small enough. The code under #else involves standard Winforms controls and works fine. The code under #if Telerik is equivalent, but does not function because I cannot add a StackLayoutPanel to the Controls collection of a form. What would be perfect is if someone could reply with a modified version of the #if Telerik code below which places the StackLayoutPanel on the form such that the form's scrollbars appear when the form is sized smaller than the panel.
AutoScroll = true;
#if Telerik
StackLayoutPanel panel = new StackLayoutPanel();
panel.Orientation = Orientation.Vertical;
panel.AutoSize = true;
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
panel.Children.Add(new RadButtonElement());
Controls.Add(panel);
#else
FlowLayoutPanel panel = new FlowLayoutPanel();
panel.FlowDirection = FlowDirection.TopDown;
panel.AutoSize = true;
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
panel.Controls.Add(new Button());
Controls.Add(panel);
#endif
You can add the StackLayoutPanel in a panel control first:
var panelControl = new RadPanel();
panelControl.PanelElement.Children.Add(panel);
Controls.Add(panelControl);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.