Hi there,
Using control version 2021.2.615
VS2019 16.10.3
I have some code using a CommandBar and CommandBarStrips as below:
//
// CommandBar
//
this.CommandBar.Dock = System.Windows.Forms.DockStyle.Top;
this.CommandBar.Location = new System.Drawing.Point(0, 25);
this.CommandBar.Name = "CommandBar";
this.CommandBar.Rows.AddRange(new Telerik.WinControls.UI.CommandBarRowElement[] {
this.CommandBarRow});
this.CommandBar.Size = new System.Drawing.Size(1241, 31);
this.CommandBar.TabIndex = 4;
this.CommandBar.ThemeName = "FluentDark";
//
// CommandBarRow
//
this.CommandBarRow.MinSize = new System.Drawing.Size(25, 25);
this.CommandBarRow.Name = "CommandBarRow";
this.CommandBarRow.Strips.AddRange(new Telerik.WinControls.UI.CommandBarStripElement[] {
this.CommandBarToolStrip,
this.CommandBarModelStrip});
//
// CommandBarToolStrip
//
this.CommandBarToolStrip.Alignment = System.Drawing.ContentAlignment.TopCenter;
this.CommandBarToolStrip.AutoSize = true;
this.CommandBarToolStrip.DisplayName = "commandBarStripElement1";
this.CommandBarToolStrip.EnableDragging = false;
this.CommandBarToolStrip.Name = "CommandBarToolStrip";
//
//
//
this.CommandBarToolStrip.OverflowButton.Enabled = false;
this.CommandBarToolStrip.OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBarToolStrip.GetChildAt(2))).Enabled = false;
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBarToolStrip.GetChildAt(2))).Visibility = Telerik.WinControls.ElementVisibility.Hidden;
//
// CommandBarModelStrip
//
this.CommandBarModelStrip.Alignment = System.Drawing.ContentAlignment.TopRight;
this.CommandBarModelStrip.AutoSize = true;
this.CommandBarModelStrip.DisplayName = "commandBarStripElement1";
this.CommandBarModelStrip.Items.AddRange(new Telerik.WinControls.UI.RadCommandBarBaseItem[] {
this.lblCurrModel,
this.CurrentModelList});
this.CommandBarModelStrip.Name = "CommandBarModelStrip";
//
//
//
this.CommandBarModelStrip.OverflowButton.Enabled = false;
this.CommandBarModelStrip.OverflowButton.Visibility = Telerik.WinControls.ElementVisibility.Hidden;
this.CommandBarModelStrip.Text = "";
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBarModelStrip.GetChildAt(2))).Enabled = false;
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBarModelStrip.GetChildAt(2))).Visibility = Telerik.WinControls.ElementVisibility.Hidden;
//
// lblCurrModel
//
this.lblCurrModel.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
this.lblCurrModel.DisplayName = "commandBarLabel1";
this.lblCurrModel.Name = "lblCurrModel";
this.lblCurrModel.Text = "Current Model : ";
//
// CurrentModelList
//
this.CurrentModelList.AutoEllipsis = true;
this.CurrentModelList.AutoSize = false;
this.CurrentModelList.Bounds = new System.Drawing.Rectangle(0, 0, 300, 24);
this.CurrentModelList.DisplayName = "commandBarDropDownList1";
this.CurrentModelList.DropDownAnimationEnabled = true;
this.CurrentModelList.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
this.CurrentModelList.MaxDropDownItems = 0;
this.CurrentModelList.Name = "CurrentModelList";
this.CurrentModelList.Text = "";
this.CurrentModelList.SelectedIndexChanged += new Telerik.WinControls.UI.Data.PositionChangedEventHandler(this.CurrentModelList_SelectedIndexChanged);
The above code compiles and runs with no issue.
If I open the designer for this form, then the above code is automatically replaced by the code below:
//
// CommandBar
//
this.CommandBar.Dock = System.Windows.Forms.DockStyle.Top;
this.CommandBar.Location = new System.Drawing.Point(0, 25);
this.CommandBar.Name = "CommandBar";
this.CommandBar.Size = new System.Drawing.Size(1241, 31);
this.CommandBar.TabIndex = 4;
this.CommandBar.ThemeName = "FluentDark";
((Telerik.WinControls.UI.CommandBarRowElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0))).Name = "CommandBarRow";
((Telerik.WinControls.UI.CommandBarRowElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0))).MinSize = new System.Drawing.Size(25, 25);
((Telerik.WinControls.UI.CommandBarStripElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(0))).Alignment = System.Drawing.ContentAlignment.TopCenter;
((Telerik.WinControls.UI.CommandBarStripElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(0))).Name = "CommandBarToolStrip";
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(2))).Enabled = false;
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(2))).Visibility = Telerik.WinControls.ElementVisibility.Hidden;
((Telerik.WinControls.UI.CommandBarStripElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1))).Alignment = System.Drawing.ContentAlignment.TopRight;
((Telerik.WinControls.UI.CommandBarStripElement)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1))).Name = "CommandBarModelStrip";
((Telerik.WinControls.UI.CommandBarLabel)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(0))).Text = "Current Model : ";
((Telerik.WinControls.UI.CommandBarLabel)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(0))).Alignment = System.Drawing.ContentAlignment.MiddleLeft;
((Telerik.WinControls.UI.CommandBarLabel)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(0))).Name = "lblCurrModel";
((Telerik.WinControls.UI.CommandBarDropDownList)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(1))).AutoSize = false;
((Telerik.WinControls.UI.CommandBarDropDownList)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(1).GetChildAt(1))).Name = "CurrentModelList";
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(2))).Enabled = false;
((Telerik.WinControls.UI.RadCommandBarOverflowButton)(CommandBar.GetChildAt(0).GetChildAt(0).GetChildAt(0).GetChildAt(1).GetChildAt(2))).Visibility = Telerik.WinControls.ElementVisibility.Hidden;
//
This code compiles but on running the first line containing all the .GetChildAt calls throws IndexOutOfRange.
Sometimes it deletes the code completely, leaving just this:
//
// CommandBar
//
this.CommandBar.Dock = System.Windows.Forms.DockStyle.Top;
this.CommandBar.Location = new System.Drawing.Point(0, 25);
this.CommandBar.Name = "CommandBar";
this.CommandBar.Size = new System.Drawing.Size(1241, 30);
this.CommandBar.TabIndex = 4;
this.CommandBar.ThemeName = "FluentDark";
Any idea what's happening here?
Many thanks,
John.