Click event on dynamically created button

2 posts, 0 answers
  1. Paul
    Paul avatar
    3 posts
    Member since:
    Jul 2017

    Posted 06 Dec 2017 Link to this post

    Hi All

    I have created buttons dynamically in vb.net using

     

    Dim rb As New RadButton

     

    How can I assign a click event to this button please?

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    2089 posts

    Posted 07 Dec 2017 Link to this post

    Hello Paul,

    You can check the following MSDN article to see how to assign an even in code using VB.NET code. You can switch between the languages for the code snippets in the article from the drop down "Language" menu on the right side of the page. In general you can do the following:
    Dim rb as New RadButton
    AddHandler rb.Click, AddressOf Onb2Click
     
    Private Sub Onb2Click(ByVal sender As Object, ByVal e As RoutedEventArgs)      
    End Sub

    I hope that helps.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top