main form contains RadCommandbar with button 'cmdNew' and other form contains RadCommandbar with button 'cmdNewR'.
Replaced button cmdNewR by cmdNew using the following function
Protected Sub ReplaceRadCommandBarButtonItem(ByVal ctlOriginal As CommandBarButton, ByVal ctlNew As CommandBarButton)
Dim owner As RadCommandBarItemsPanel = CType(ctlOriginal.Parent, RadCommandBarItemsPanel)
Dim originalIndex As Integer = owner.Children.IndexOf(ctlOriginal)
owner.Children.Remove(ctlOriginal)
owner.Children.Insert(originalIndex, ctlNew)
End Sub
The cmdNewR button in command bar will replaced by cmdNew. but click event is not hitting
Private Sub cmdNewR_Click(sender As Object, e As EventArgs) Handles cmdNewR.Click
NewFileClicked()
End Sub
Private Sub cmdNew_Click(sender As Object, e As EventArgs)
NewFileClicked()
End Sub
To reproduce: - Add RadCommanBar to a form and the shown and close the form several times.
DECLINED: RadCommandBar assigns the DesiredLocation of each strip on the first layout pass and keeps this value until a different one is explicitly specified (via drag or via setting the property). The difference in the initial DesiredSize of the strips (depending on whether they have the grip/overflow button collapsed) results in different initial DesiredLocation settings. The proper way to avoid the gaps is to explicitly set the DesiredLocation property of each strip when collapsing the grips and overflow buttons. To reproduce: 1.Add a RadCommandBar with several CommandBarStripElement. Each strip should contain a single button element. 2.Add a RadButton. 3.Use the following code snippet: private Dictionary<ElementVisibility, ElementVisibility> toggle; public Form1() { InitializeComponent(); toggle = new Dictionary<ElementVisibility, ElementVisibility>(); toggle[ElementVisibility.Collapsed] = ElementVisibility.Visible; toggle[ElementVisibility.Hidden] = ElementVisibility.Visible; toggle[ElementVisibility.Visible] = ElementVisibility.Collapsed; } private void ButtonClick() { foreach (var row in radCommandBar1.Rows) { foreach (var strip in row.Strips) { Toggle(strip); } } } private void radButton1_Click(object sender, EventArgs e) { ButtonClick(); } private void Toggle(Telerik.WinControls.UI.CommandBarStripElement strip) { Toggle(strip.Grip); Toggle(strip.OverflowButton); } private void Toggle(Telerik.WinControls.RadElement element) { element.Visibility = toggle[element.Visibility]; } If you collapse the Grip and the OverflowButton of a CommandBarStripElement, there is a gap between CommandBarStripElements. Workaround: call the ButtonClick method in the form constructor.