Results 1 to 5 of 5

Thread: [RESOLVED] user control

  1. #1

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Resolved [RESOLVED] user control

    hi,
    I created my own user control it composed of button,label and a picturebox the problem is how to add an on click event in my control?
    VB Code:
    1. private usercontrolname pb1 = new usercontrolname ();      
    2. pb1.Click += new System.EventHandler(ako);
    I have already this one in my code but when I click the button the event wasn't fired. the event occur when i click outside the button in my user control.

    pls. help me.

    Popskie

  2. #2
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Re: user control

    You have implemented the Click Method for the control, not the OnClick event for the Button.

    You can either... Expose the button by making a property that encapsulates the button used on your form, you will be able to add the event like this..

    private usercontrolname pb1 = new usercontrolname ();
    pb1.MyButton.Click += new System.EventHandler(ako);

    or you could add your own event that gets fired when the user clicks the button.

    Rohan
    You dont need eyes to see, you need vision.

  3. #3

    Thread Starter
    Fanatic Member popskie's Avatar
    Join Date
    Jul 2005
    Location
    In my chair
    Posts
    666

    Re: user control

    so i need to declare the properties of button modifier as public. Am i correct?

  4. #4
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Re: user control

    You can do that

    or make a property like this

    public Button MyButton
    {
    get{return buttonOnForm;}
    }
    You dont need eyes to see, you need vision.

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width