Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

User Control Event Handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason MacKenzie - 12 Oct 2004 19:49 GMT
I have a user control (inheriting from System.Windows.Forms.UserControl)
with a button on it. I've added the control to the toolbox and have dragged
it onto a form from another project.

How can I capture the click event of the button in the parent form?
Currently nothing happens when I click the button.

Any help is appreciated,

Jay
Sijin Joseph - 13 Oct 2004 05:24 GMT
One way would be to write an event in your usercontrol and fire that
event when the button in the user control is clicked.

public event EventHandler ButtonClicked;

public void button_click(object sender,EventArgs e)
{
    if(Butonclicked != null)
    {
        Buttonclicked(sender,e);
    }
}

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> I have a user control (inheriting from System.Windows.Forms.UserControl)
> with a button on it. I've added the control to the toolbox and have dragged
[quoted text clipped - 6 lines]
>
> Jay
Jason MacKenzie - 13 Oct 2004 11:28 GMT
Thank you sir. That worked fantastically.

> One way would be to write an event in your usercontrol and fire that event
> when the button in the user control is clicked.
[quoted text clipped - 23 lines]
>>
>> Jay

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.