It is possible to add one control, but when when you try to add other controls to the layout, just sits where you place it rather than split in to sections.
Expected:
Actual:
I can not add any type of control to the layoutControlGroupItem. I have a screen recording of me trying to follow the procedure shown but it is 60M so I can't attach it. I shared the file on my OneDrive if you would like to access it that way.
To reproduce:
private void RadButton5_Click(object sender, EventArgs e)Workaround:
private void RadButton5_Click(object sender, EventArgs e)
{
RadButton labelControl = new RadButton();
labelControl.Size = new Size(200, 30);
labelControl.Text = "Test";
((RadLayoutControlControlCollection)this.radLayoutControl1.Controls).RemoveInternal(layoutControlItem1.AssociatedControl);
((RadLayoutControlControlCollection)this.radLayoutControl1.Controls).AddInternal(labelControl);
layoutControlItem1.AssociatedControl = labelControl;
layoutControlItem1.UpdateControlBounds();
}
Hide Item option in the context menu should not be present for those items. We should also consider a cancellable ItemHiding event. The custom control below handles this scenario: public class CustomRadLayoutControl : RadLayoutControl { public override string ThemeClassName { get { return typeof(RadLayoutControl).FullName; } } protected override void InitializeDropDownMenu() { FieldInfo hideMenuItemFi = typeof(RadLayoutControl).GetField("hideMenuItem", BindingFlags.Instance | BindingFlags.NonPublic); RadMenuItem hideMenuItem = hideMenuItemFi.GetValue(this) as RadMenuItem; if (hideMenuItem == null) { hideMenuItemFi.SetValue(this, new RadMenuItem(LayoutControlLocalizationProvider.CurrentProvider.GetLocalizedString(LayoutControlStringId.ContextMenuCustomize))); hideMenuItem = hideMenuItemFi.GetValue(this) as RadMenuItem; } hideMenuItem.Click += customizeItem_Click; RadDropDownMenu menu = typeof(RadLayoutControl).GetField("dropDownMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as RadDropDownMenu; menu.Items.Add(hideMenuItem); } private void customizeItem_Click(object sender, EventArgs e) { if (this.AllowCustomize) { this.ShowCustomizeMenuDialog(); } } private void ShowCustomizeMenuDialog() { if (this.CustomizeDialog.Visible) { return; } this.ShowCustomDragOverlay(); this.CustomizeDialog.Owner = this.FindForm(); ThemeResolutionService.ApplyThemeToControlTree(this.CustomizeDialog, this.ThemeName); if (this.CustomizeDialog.Location == Point.Empty) { this.CustomizeDialog.Location = GetInitialCustomizeDialogLocation(); } this.CustomizeDialog.Show(); this.CustomizeDialog.RightToLeft = this.RightToLeft; } private void ShowCustomDragOverlay() { FieldInfo dragOverlayFi = typeof(RadLayoutControl).GetField("dragOverlay", BindingFlags.Instance | BindingFlags.NonPublic); LayoutControlDraggableOverlay dragOverlay = dragOverlayFi.GetValue(this) as LayoutControlDraggableOverlay; if (dragOverlay == null) { dragOverlayFi.SetValue(this, new CustomLayoutControlDraggableOverlay(this)); dragOverlay = dragOverlayFi.GetValue(this) as LayoutControlDraggableOverlay; } dragOverlay.ThemeName = this.ThemeName; dragOverlay.UpdatePreview(); dragOverlay.Dock = DockStyle.Fill; ((RadLayoutControlControlCollection)this.Controls).AddInternal(dragOverlay); dragOverlay.Visible = true; dragOverlay.BringToFront(); this.PerformLayout(); this.Refresh(); } } public class CustomLayoutControlDraggableOverlay : LayoutControlDraggableOverlay { private RadMenuItem hideMenuItem; public CustomLayoutControlDraggableOverlay(RadLayoutControl owner) : base(owner) { RadDropDownMenu contextMenu = typeof(LayoutControlDraggableOverlay).GetField("contextMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this) as RadDropDownMenu; contextMenu.Items.Clear(); this.hideMenuItem = new RadMenuItem(LayoutControlLocalizationProvider.CurrentProvider.GetLocalizedString(LayoutControlStringId.ContextMenuHideItem)); this.hideMenuItem.Text = LayoutControlLocalizationProvider.CurrentProvider.GetLocalizedString(LayoutControlStringId.ContextMenuHideItem); this.hideMenuItem.Click += hideMenuItem_Click; contextMenu.Items.Add(hideMenuItem); contextMenu.DropDownOpening += ContextMenu_DropDownOpening; } private void ContextMenu_DropDownOpening(object sender, CancelEventArgs e) { if (this.SelectedItems.Count == 1 && this.SelectedItems[0].Name == "layoutControlItem4") { e.Cancel = true; } } private void hideMenuItem_Click(object sender, EventArgs e) { foreach (DraggableLayoutControlItem item in this.SelectedItems) { if (item.Name == "layoutControlItem4") { continue; } ((CustomRadLayoutControl)this.Owner).HideItem(item.AssociatedItem); } this.UpdatePreview(); } }
Workaround: handle the RadPropertyChanging and RadPropertyChanged public partial class RadForm1 : Telerik.WinControls.UI.RadForm { public RadForm1() { InitializeComponent(); this.layoutControlGroupItem1.RadPropertyChanging += LayoutControlGroupItem1_RadPropertyChanging; this.layoutControlGroupItem1.RadPropertyChanged += LayoutControlGroupItem1_RadPropertyChanged; } private void LayoutControlGroupItem1_RadPropertyChanged(object sender, RadPropertyChangedEventArgs e) { if (e.Property == LayoutControlGroupItem.IsExpandedProperty) { Console.WriteLine("IsExpanded Changed"); Console.WriteLine("Old Value: " + e.OldValue); Console.WriteLine("New Value: " + e.NewValue); } } }
Workaround: set a White back color to the control in the designer or use the attached custom theme
To reproduce: - Add layout control to a standard Form. - Make the form smaller so a scrollbar appears in the layout control. - There is an exception when you are scrolling. Workaround: Use RadForm instaed.
To reproduce: - Start the attached project. - Collapse and then expand the group. - The label should remain hidden. Workaround: bool labelVisiable = false; private void TxtIdNro_VisibleChanged(object sender, EventArgs e) { if (txtIdNro.Visible && !labelVisiable) { txtIdNro.Visible = false; } }
Please run the attached sample project and follow the steps in the document locate din the zipped folder. Workaround: this.radLayoutControl1.VerticalScrollbar.ValueChanged += VerticalScrollbar_ValueChanged; private void VerticalScrollbar_ValueChanged(object sender, EventArgs e) { this.Width += 1; this.Width -= 1; }
Workaround: access the tabbed group and remove the group item manually this.layoutControlTabbedGroup1.ItemGroups.Remove(this.layoutControlGroupItem1); this.radLayoutControl1.HiddenItems.Add(this.layoutControlGroupItem1);
The attached video shows how this can be reproduced. Workaround: private void RadLayoutControl1_MouseWheel(object sender, MouseEventArgs e) { HandledMouseEventArgs ee = (HandledMouseEventArgs)e; ee.Handled = true; }
To reproduce: - Open the attached project. - Select the second tab and then the inner tabs. - The layout is not updated. Workaround: private void TabStrip_ItemSelected(object sender, RadPageViewItemSelectedEventArgs e) { LayoutControlTabStripElement el = sender as LayoutControlTabStripElement; foreach (LayoutControlTabStripItem item in el.Items) { var groupItem = item.LayoutGroupItem; groupItem.Visibility = Telerik.WinControls.ElementVisibility.Visible; groupItem.InvalidateMeasure(true); groupItem.InvalidateArrange(true); groupItem.UpdateLayout(); groupItem.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } foreach (LayoutControlTabStripItem item in el.Items) { if (item == e.SelectedItem) { var groupItem = item.LayoutGroupItem; groupItem.Visibility = Telerik.WinControls.ElementVisibility.Visible; break; } } } // access event layoutControlTabbedGroup4.TabStrip.ItemSelected += TabStrip_ItemSelected;
I have come from experience with using the DevExpress layoutcontrol and unfortunately theirs is far more matured than yours. Some improvements i strongly think you should make to allow this control to be a part of every Winforms app: 1) Intelligent auto-enabling of "DrawText": Input style controls (TextBox, Combobox, listbox, etc) should have DrawText enabled by default, while others (Label, Buttons, etc) should have it false by default. 2) Text for added controls should be sized better: At the moment, you can only choose from "proportional" or "fixed". The problem is that "Proportional" never looks good as it creates too much space for the label, and "fixed" forces me to have to make a decision on how big i want it, and if later on i add something that is larger, i now have to go though all the controls and update their size. A Better solution would be to have an "auto" option that behaves like "fixed" but sizes all on the labels in the same container also set to "auto" to the greatest of all of them. 3) Size the LayoutControl relevant to the control that it is containing: A Textbox generally has fixed height, so making the layoutControl larger than it just leaves unusual spacing. This is more pronounced the more controls you have being laid out. Moreso, this even allows the child controls to grow larger than its container, potentially having them overlapping other controls. This to me defeats the purpose of a dynamic layout. So far, the only way i have managed to achieve a consistent layout regardless of window/form size is to set the min/max size of the LayoutControlItem which is cumbersome. 4) Right-click context menu at design time: Take the DevEx one for a spin. Right click on a layout control and you can do things from hiding/showing text, fixing width and/or height, can multiselect and then click "Create Group". This alone would cover my first suggestion. 5) Add panels to the layout control: At the moment, once you add a panel to the layout control, you can no longer layout the panels contents as any control you try to adjust will try to snap to the LayoutControl. Sometimes your design requirements will be outside of what the LayoutControl can provide. 6) The "Customize" overlay is neat but...: I like how this allows me to focus entirely on laying out the "LayoutControlItems" however, sometimes you need to modify the properties of the LayoutControlItems to get the desired changes and as the properties window is no longer accessible (due to a modal popup i guess) this is fairly crippling. Considering that nearly all of the needed layout functions are accessible only through the properties (i.e setting min and max sizes to constrain proportions. See item 3 about this), it means i cannot use the Customize mode to its full potential. Perhaps taking advantage of your Properties editor to appear in the customize overlay would alleviate this problem? If you are a winforms developer, chances are you are using the designer to lay things out and the LayoutControl is potentially a fantastic tool to augment this.
Currently you cannot add any controls to a panel which is already inside RadLayoutControl.
radlayoutcontrol does not support System.Windows.Forms.TextBox autosize in multiline mode but supports radTextBox, Please considere fizing that bug. take a look at the attached picture