Click here to Skip to main content
15,905,233 members
Home / Discussions / C#
   

C#

 
QuestionAn elevator Problem Pin
ebey4-Mar-07 18:18
ebey4-Mar-07 18:18 
AnswerRe: An elevator Problem Pin
benjymous5-Mar-07 1:37
benjymous5-Mar-07 1:37 
QuestionEnabling checkbox functioanlity in datagrid Pin
salon4-Mar-07 17:48
salon4-Mar-07 17:48 
QuestionAssigning a TextBox object to another TextBox object Pin
GunaChinna4-Mar-07 17:32
GunaChinna4-Mar-07 17:32 
AnswerRe: Assigning a TextBox object to another TextBox object Pin
S. Senthil Kumar4-Mar-07 18:46
S. Senthil Kumar4-Mar-07 18:46 
GeneralRe: Assigning a TextBox object to another TextBox object Pin
GunaChinna4-Mar-07 19:34
GunaChinna4-Mar-07 19:34 
Questionadding an item to context menu Pin
Muhammad Ashraf Nadeem4-Mar-07 17:06
Muhammad Ashraf Nadeem4-Mar-07 17:06 
AnswerRe: adding an item to context menu Pin
Luc Pattyn4-Mar-07 18:41
sitebuilderLuc Pattyn4-Mar-07 18:41 
Hi,

I'm not sure what your question is.

If you are creating a program (in C# as implied by this forum) then you
want to use the ContextMenu.Popup event to clear, then populate your
context menu with items that depend on the item for which context is requested.
Code would include things such as:

// once, probably in constructor
	contextMenu.Popup+=new System.EventHandler(myPopup);

// event handler
private void myPopup(object sender, EventArgs e) {
	Menu menu=sender as Menu;
	menu.MenuItems.Clear();
	mi=addMenuItem(menu, "Copy File", new EventHandler(CopyFileHandler));
	mi.Enabled=LongNameIsFileSpec;
	mi=addMenuItem(menu, "Explore", new EventHandler(ExploreHandler));
	mi.Enabled=LongNameIsFileSpec;
	...
}

protected MenuItem addMenuItem(Menu menu, string text, EventHandler handler) {
	return addMenuItem(menu, text, Shortcut.None, handler);
}

protected MenuItem addMenuItem(Menu menu, string text, Shortcut sc, 
		EventHandler handler) {
	MenuItem menuItem=new MenuItem(text);
	menuItem.Click+=handler;
	menuItem.Shortcut=sc;
	menu.MenuItems.Add(menuItem);
	menuItem.Enabled=handler!=null;
	return menuItem;
}


If you are referring to the context menu presented by Windows Explorer,
there are basically two ways to add user defined menu items:
- you can add an item for all files, all folders, or all files+folders by
creating the right entries in the System's Registry
- you can have Explorer start a small user-provided program to dynamically
add one or more context menu items very time something gets right clicked.

Hope this helps.

Smile | :)


Luc Pattyn

[My Articles]

QuestionRe: adding an item to context menu Pin
Muhammad Ashraf Nadeem4-Mar-07 19:53
Muhammad Ashraf Nadeem4-Mar-07 19:53 
AnswerRe: adding an item to context menu Pin
jjansen5-Mar-07 0:46
jjansen5-Mar-07 0:46 
AnswerRe: adding an item to context menu Pin
Luc Pattyn5-Mar-07 12:30
sitebuilderLuc Pattyn5-Mar-07 12:30 
Questionrun through every possiblity [modified] Pin
crash8934-Mar-07 16:48
crash8934-Mar-07 16:48 
AnswerRe: run through every possiblity Pin
DavidNohejl5-Mar-07 0:31
DavidNohejl5-Mar-07 0:31 
GeneralRe: run through every possiblity Pin
crash8935-Mar-07 12:34
crash8935-Mar-07 12:34 
QuestionCustom Control and Passing Events Pin
Expert Coming4-Mar-07 16:09
Expert Coming4-Mar-07 16:09 
AnswerRe: Custom Control and Passing Events Pin
pbraun5-Mar-07 8:21
pbraun5-Mar-07 8:21 
Questionrandom number problem Pin
xp20064-Mar-07 15:34
xp20064-Mar-07 15:34 
AnswerRe: random number problem Pin
Sylvester george4-Mar-07 20:12
Sylvester george4-Mar-07 20:12 
GeneralRe: random number problem Pin
xp20064-Mar-07 20:52
xp20064-Mar-07 20:52 
AnswerRe: random number problem Pin
Rudolf Jan5-Mar-07 0:40
Rudolf Jan5-Mar-07 0:40 
QuestionServer's responce code Pin
Andrey@Ukraine4-Mar-07 14:40
Andrey@Ukraine4-Mar-07 14:40 
QuestionArchitecture and C# Pin
aecordoba4-Mar-07 14:25
aecordoba4-Mar-07 14:25 
AnswerRe: Architecture and C# Pin
DavidNohejl5-Mar-07 0:36
DavidNohejl5-Mar-07 0:36 
AnswerRe: Architecture and C# Pin
DavidNohejl5-Mar-07 1:07
DavidNohejl5-Mar-07 1:07 
GeneralRe: Architecture and C# Pin
aecordoba5-Mar-07 4:50
aecordoba5-Mar-07 4:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.