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 / December 2004

Tip: Looking for answers? Try searching our database.

Delegating Menu Commands

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ian.mcewan@atonement.net - 07 Dec 2004 11:33 GMT
Hi,

I have three menu user controls (this is for touchscreen
application so they can't be .Net/XP menus).

These menus all represent a common pool of commands, but
for example menu1 has command1, command2, command3,
whereas menu2 has only command2, and so on.

What is the simplest way (preferably without inordinate
redesign and abstraction) to implement ALL the commands
in one class and then hook up the menu user controls to
that class?

Thanks
Ian.
Nigel Armstrong - 07 Dec 2004 12:49 GMT
Hi Ian

You could use the MenuItem constructor that has the EventHandler delegate
argument. Code from my head, so untested!

HTH

Nigel Armstrong

VB:

Public Class Commands
  Public Sub Command1(ByVal sender As Object, ByVal e As EventArgs)
 
  End Sub
'etc

End Class

In the form

Dim c As New Commands
Dim menu1 As New MenuItem("Text", AddressOf c.Command1)

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks
> Ian.

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.