Declined
Last Updated: 14 Aug 2020 10:30 by ADMIN
Binshidha
Created on: 12 Aug 2020 08:37
Category: CommandBar
Type: Bug Report
1
Event not firing in Commandbar button in RadCommandbar button
  • I have one main form in which a radcommand bar is defined
  • other forms inherits this form and replace the commandbarbuttons in the forms with the commandbar buttons in main form
  • Successfully replaced the buttons, but the events are not firing after clicking the button.

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

 
8 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 14 Aug 2020 10:30

Hi, Binshidha,

I have noticed that you have opened a new bug report in our feedback portal on this topic. Here is the link for your reference: https://feedback.telerik.com/winforms/1480450-command-bar-button-text-is-not-displaying We will handle this case there. Please, see our answer there for more information.

We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more public items instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a public feedback item.

In addition, creating a public feedback item is usually related to a feature request submission or a bug report. In case you are not sure whether the undesired behavior is an issue in the Telerik UI for WinForms suite, feel free to submit a support ticket from your Telerik account. Thus, the support engineers would gladly assist you. 

Thank you for your understanding.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Binshidha
Posted on: 13 Aug 2020 15:44
please ignore last added comment
Binshidha
Posted on: 13 Aug 2020 13:25

Hi Dess,

I have encountered some other issue here. text of the button is not displaying in this case.

I have set DrawText property as true, UseCompatibleTextRendering as true and TextImageRelation as true. still the text is not displaying only the image is showing. Could you please go throgh the same project again

Thanks

Binshidha

Binshidha
Posted on: 13 Aug 2020 12:05

Hi Dess,

Thanks for the solution, it is working as expected

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 13 Aug 2020 10:47

Hello, Binshidha,

The provided sample project is greatly appreciated. I was able to observe the described problem.

However, I have noticed that the previously explained approach for managing the elements inside a RadCommandBar via the CommandBarStripElement and its Items collection is commented. Once I uncomment it, everything seems to work as expected with applying the dark theme as well: 

 
    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)
        Dim owner As RadCommandBarItemsPanel = CType(ctlOriginal.Parent, RadCommandBarItemsPanel)
        Dim parentStrip As CommandBarStripElement = TryCast(owner.Parent, CommandBarStripElement)
        Dim originalIndex As Integer = parentStrip.Items.IndexOf(ctlOriginal)
        'remove the parent buton
        parentStrip.Items.Remove(ctlOriginal)

        'remove the child button from the child commandbar
        Dim childStrip As CommandBarStripElement = TryCast(ctlNew.Parent.Parent, CommandBarStripElement)
        childStrip.Items.Remove(ctlNew)

        'insert the child button
        parentStrip.Items.Insert(originalIndex, ctlNew)
    End Sub

Could you please confirm whether it works as expected when managing the buttons in the appropriate way?

Managing the RadCommandBarItemsPanel.Children collection is not recommended and I can't ensure that it will behave properly.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Attached Files:
Binshidha
Posted on: 12 Aug 2020 18:42

Hi Dess,

I  am attaching the sample code. In this project click event worked properly.

In my actual project  click event is not working, I have found the issue behind it. I am using visual style builder in the project, when applying the theme click event is not firing. (I checked without applying the theme from vsb, at that time click event is getting.)

In the project zip file, you can see the theme that I used as package

and I have attached another file which contains xml files of themes used

 

Thanks ,

Binshidha

Attached Files:
Binshidha
Posted on: 12 Aug 2020 18:28

Hi Dess,

I  am attaching the sample code. In this project click event worked properly.

In my actual project  click event is not working, I have found the issue behind it. I am using visual style builder in the project, when applying the theme click event is not firing. (I checked without applying the theme from vsb, at that time click event is getting.)

In the zip file, you can see the theme that I used

 

Thanks ,

Binshidha

Attached Files:
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 12 Aug 2020 11:43

Hello, Binshidha,

Following the provided information, I have prepared a sample project to test the behavior on my end.

One thing is not quite clear to me. That is why I need some more clarification. If you have a MainForm and a ChildForm which inherits the MainForm, is the RadCommandBar in the ChildForm the inherited one or you add an additional one?

Please refer to the attached sample project.

If we don't manage the buttons, both buttons are visible:

After executing the code in the ReplaceRadCommandBarButtonItem method, the button from the child commandbar is correctly inserted in the parent commandbar:

Please have in mind that if you want to manage the elements inside a RadCommandBar, the appropriate way to do it is via the CommandBarStripElement and its Items collection.

If it is not he exact scenario that you have, feel free to modify the project in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik