473,569 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to create dynamic event handlers

i'm building an desktop windows app in C#. the main menu for the
application will be different depending on the admin rights of the
user. i've built the entire app. in delphi and i simply activated or
deactivated the menu items in that case, but all the menu items are
visble. i'm hoping / thinking that with .NET, i can dynamically
generate the click events for the dynamically generated menu, so that
only the menu items, that a particular user has access to will show,
along with their events. is this possible?

May 8 '06 #1
2 1620
Hope I have understood your Question correctly , this might be the solution
When menu is created , put the following code on run time
toolBarLabel.Cl ick += new System.EventHan dler(ToolBarLab el.Click);

"mike" wrote:
i'm building an desktop windows app in C#. the main menu for the
application will be different depending on the admin rights of the
user. i've built the entire app. in delphi and i simply activated or
deactivated the menu items in that case, but all the menu items are
visble. i'm hoping / thinking that with .NET, i can dynamically
generate the click events for the dynamically generated menu, so that
only the menu items, that a particular user has access to will show,
along with their events. is this possible?

May 8 '06 #2
mike wrote:
i'm building an desktop windows app in C#. the main menu for the
application will be different depending on the admin rights of the
user. i've built the entire app. in delphi and i simply activated or
deactivated the menu items in that case, but all the menu items are
visble. i'm hoping / thinking that with .NET, i can dynamically
generate the click events for the dynamically generated menu, so that
only the menu items, that a particular user has access to will show,
along with their events. is this possible?


You can always do that with the += and =- to add or remove handlers.

Or you could have menu items and .Enable them as needed.

I do this in one of my clients that has an Edit and Read mode:
if(Configuratio nSettings.AppSe ttings["Mode"].Equals("Edit") )
edit=true;

switch(nlevel){
case 1:

//(A) Add a RowBayLevel node.
this.menuItem1. Enabled=edit; //add
this.menuItem3. Enabled=false; //delete
this.menuItem2. Enabled=false; //change
this.menuItem4. Enabled=false; //move
break;
May 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3573
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
2
1909
by: RA | last post by:
Hi I have a dynamic asp.net table created from the database. I am adding an ImageButton to each row so the client can click on it. Each ImageButton has the ID = orderid from database. How can I receive the click event when the user clicks one of the buttons. Eventually I would like to do the same processing for all buttons depending on...
13
3489
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the following issues still exist. The article shows how to find methods on a receiver that match the pattern OnXXXX given the sender. It loops through...
1
1569
by: Samuel R. Neff | last post by:
Is there any way to create a generic event handler that can be subscribed to any event? If I have a sub.. Private Sub DataTable_SomethingChanged(sender As Object, e As System.EventArgs) and subscribe it to AddHandler dataTable.ColumnChanged, AddressOf SomethingChanged
2
1483
by: mike | last post by:
i'm building an desktop windows app in C#. the main menu for the application will be different depending on the admin rights of the user. i've built the entire app. in delphi and i simply activated or deactivated the menu items in that case, but all the menu items are visble. i'm hoping / thinking that with .NET, i can dynamically generate...
5
1416
by: Chris | last post by:
Is there any way you can dynamically add an event and then some code. I get it that you could, in your code, add a control and dynamically add an event handler for e.g. the click event. However the code within the event handler, could that be pulled from a database and ran. I would like to create a form in which I could populate it's...
1
1844
by: Dica | last post by:
i've got a script that loops through a dataset and creates dynamic web controls and event handlers: while (oDr.Read()){ RadioButton oRb = new RadioButton(); oRb.ID = oDr.ToString(); oRb.AutoPostBack = true; oRb.CheckedChanged += new System.EventHandler(this.clientRadioButton_click); }
3
3001
by: =?Utf-8?B?ZWFndWlsYXI=?= | last post by:
Hi, I am trying to dynamically generate a menu, based on entries on a text or xml file. The text file contains the "tree" after which the menu will need to be created. Something like the following: Level 1 -- Level 2 -- Level 2 Level 1
10
9555
Plater
by: Plater | last post by:
I'm a bit boggled by this since I am rather new to using reflection. I want to attach an event handler via Reflection (which I can do), but I want to NOT have to know the exact event delegate signature. For an exmaple, I have a .DLL with the following: public delegate CustomEnum CustomEventHandler(Socket s, CustomClass c); public class...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.