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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tollbar button calling a command button

Status
Not open for further replies.

hugh999

MIS
Nov 29, 2001
129
IE
Hi
How do you call the code behind a command button from a button on a toolbar.

I have a command button "cmdBrowse" that opens a browse dialog and would like a button on my toolbar to perform the same action. ie: place code behind the toolbar button that calls the "cmdBrowse" button.

Thanks
 
You can either assign them a common event handler, or have them call a common function that contains all of the processing logic.
 
When the child form loads, you attach the toolbar button's Click event to cmdBrowse's Click handler (eg cmdBrowse_Click(object ...) )via a delegate. But when it loses focus, detach the handler again. You do this to disallow calling cmdBrowse when the concerned child form deactivates or loses focus.

Read about C# delegate on MSDN.

Hope this helps. [peace]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top