help adding button in code


  • ok, so I have drawn my button onto my windows form and it appears nicely. however how do I put a click event so I can click the button? this is what I have at the moment. abit naughty of my as im using VB.net using visual studio 2013.
    Dim startbutton As New Button
            With startbutton
                .Text = "Play"
                .Name = "btnPlay"
                .Location = New Point(200, 225)
                .Size = New Size(100, 50)
            End With

    Jordan Payne

    Tuesday, May 27, 2014 10:52 PM


  • Are you writing a Windows Store app or a Windows Form app? This forum is for help writing Windows Store apps. The code snippet you mention appears to be a Windows Form as the Windows.UI.Xaml.Controls.Button doesn't have a Text property.

    Either way you can wire up events with the AddHandler statement.

    If you're just starting out writing Windows Store apps I highly recommend going through the C#/VB and XAML tutorials .

    Tuesday, May 27, 2014 11:39 PM