Results 1 to 4 of 4

Thread: How To : User Control

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Question How To : User Control

    Hi all


    I've created a user control that contains 3 buttons Add / Modify / Delete. The click events of the controls are calling abstract methods. I'm placing the control on a form, form1.cs file, i would like to call a specific method for the click of the add button of the control. Can anybody help me on accomplishing this?
    Pavan Kumar

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: How To : User Control

    You should raise the click events for each button in your control so that you can handle them in your form. Take a look at this event bubbling sample on MSDN:

    http://msdn.microsoft.com/library/de...trolsample.asp

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    134

    Re: How To : User Control

    Thanks Mendhak.

    But the link you provided did not help me much. So can you pls. give me an example or a link for an example so that I can get more r clear soln. My actual problem is i have a user control which is having command button add I placed user control in my class from1.cs when I click on the user control add button, Adding() method should be call in the form1.cs. how to do this task.

    Quote Originally Posted by mendhak
    You should raise the click events for each button in your control so that you can handle them in your form. Take a look at this event bubbling sample on MSDN:

    http://msdn.microsoft.com/library/de...trolsample.asp
    Pavan Kumar

  4. #4
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Re: How To : User Control

    You could just do this
    Code:
    UserControl.Parent.Adding()
    But actually I dont think this is good application design! Have alook at mendhaks solution, let your userForm raise an event when Button add is clicked. Have your form subscribe to that event and handle what to do there!

    HTH,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

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