Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about using default command button and one I've classed 1

Status
Not open for further replies.

bernardmanning

Programmer
Oct 14, 2003
61
GB
Hopefully this will be a real simple question...

if I drop a native instrinsic command button onto a native win form, I can then double click the command button and place code in it's click event eg;

Code:
Public Class cleanform
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("this is my intrisic button")
    End Sub
End Class

and it works great...dead easy....

If I then create a button class so that all my button look the same have the same colours etc..
build the class,
add it to my controls toolbar
create a new form
drag the classed button onto a form,

I can't seem to get code into the click event as I can with the ordinary non classed button.

heres the code for my class ;

Code:
Public Class TestButton
    Inherits System.Windows.Forms.UserControl

EndClass

any body give me any clues?

Thanks, Bernard..
 
shouldn't the testbutton be inheriting from the button class instead of the usercontrol class.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Hi Christiaan, thanks for the reply

I've created this class visually,is this the problem?

I create a class library project, go add / add user control, select user control and click ok, I then drop a button on to this.

should I be creating the class in code?

Thanks, Bernard....



 
Yep, creating it in code did the trick...

Code:
Public Class Class1
    Inherits System.Windows.Forms.Button


End Class

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top