Button Click Event

3 posts, 1 answers
  1. Celeste Zietsman
    Celeste Zietsman avatar
    17 posts
    Member since:
    Apr 2010

    Posted 05 Apr 2011 Link to this post

    Hi

    I have created a button in code like this:

     

     

    Dim RadRibbonBarGroup_Main = New RadRibbonBarGroup()

     

     

     

     

    Dim RadRibbonBarButtonGroup_Main = New RadRibbonBarButtonGroup

     

     

     

    Dim btnExtract As New RadButtonElement()

     

     

    RadRibbonBarGroup_Main.Items.AddRange(

     

    New Telerik.WinControls.RadItem() {RadRibbonBarButtonGroup_Main})

     

     

    RadRibbonBarGroup_Main.Name =

     

    "RadRibbonBarGroup_Main"

     

    RadRibbonBarGroup_Main.Text =

     

    "Extract Data"

     

    RadRibbonBarGroup_Main.Alignment =

     

    ContentAlignment.TopCenter

     

     

    btnExtract.Name =

     

    "btnExtract"

     

    btnExtract.Text =

     

    "Extract"

     

    btnExtract.Class =

     

    "ButtonElement"

     

    btnExtract.Image =

     

    Global.culminTelFormLib.My.Resources.Resources.Database_export_32()

     

     

    btnExtract.ImageAlignment = System.Drawing.

     

    ContentAlignment.MiddleCenter

     

     

    btnExtract.TextImageRelation = System.Windows.Forms.

     

    TextImageRelation.ImageAboveText

     

     

    RadRibbonBarButtonGroup_Main.Items.AddRange(

     

    New Telerik.WinControls.RadItem() {btnExtract})

     

     

    RadRibbonBarButtonGroup_Main.Name =

     

    "RadRibbonBarButtonGroup_Main"

     

    RadRibbonBarButtonGroup_Main.Text =

     

    "RadRibbonBarButtonGroup_Main"

     

    RadRibbonBarButtonGroup_Main.Alignment =

     

    ContentAlignment.TopCenter

     

     

     

     

    Me.tabHome.Items.Insert(0, RadRibbonBarGroup_Main)

     



    Now I want to use the click event. How would I go about doing this?

    I have tried adding the following code to the form but it still does not work. What am I doing wrong?:

    Public WithEvents btnExtract As Telerik.WinControls.UI.RadButtonElement


     

     

    Protected Sub btnExtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExtract.Click

     

     

     

     

    If IsNothing(frmLoad) Then

     

    frmLoad =

     

    New frmTaxSageLoad

     

    frmLoad.Show()

    frmLoad.WindowState =

     

    FormWindowState.Maximized

     

     

     

     

    Else

     

    frmLoad.BringToFront()

     

     

    End If

     

     

     

    End Sub

     


    Thanks
    Celeste
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Apr 2011 Link to this post

    Hello,

    To create the click event handler you can manually add a handler to the button. For more information on AddHandler, please refer to this MSDN link

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Celeste Zietsman
    Celeste Zietsman avatar
    17 posts
    Member since:
    Apr 2010

    Posted 06 Apr 2011 Link to this post

    Hi Richard

    Thanks, I got it working now.

    Regards
    Celeste
Back to Top