Click here to Skip to main content
15,915,501 members
Home / Discussions / C#
   

C#

 
GeneralRe: Need some help with regex Pin
FreeClimber11-Nov-05 11:25
FreeClimber11-Nov-05 11:25 
QuestionCreating a new table of smaller dataset. Pin
zaboboa11-Nov-05 9:29
zaboboa11-Nov-05 9:29 
AnswerRe: Creating a new table of smaller dataset. Pin
rudy.net11-Nov-05 11:04
rudy.net11-Nov-05 11:04 
QuestionHow to rename mapped drive? Pin
Shumsky11-Nov-05 8:51
Shumsky11-Nov-05 8:51 
QuestionBinary Formatter problems Pin
Marc Clifton11-Nov-05 8:37
mvaMarc Clifton11-Nov-05 8:37 
AnswerRe: Binary Formatter problems Pin
leppie11-Nov-05 10:47
leppie11-Nov-05 10:47 
AnswerRe: Binary Formatter problems Pin
Joe Woodbury11-Nov-05 20:30
professionalJoe Woodbury11-Nov-05 20:30 
QuestionWhy is there a ContextMenu Property on TreeView? Pin
SeanCM11-Nov-05 8:35
SeanCM11-Nov-05 8:35 
Hi,

I am fairly new at C# and Windows programming. I am a bit confused why the TreeView has a ContextMenu property when you can not really use ContextMenu_Popup Handler when it does not accurately give you the mouse coordinates. OK I am not being clear, take this code for example:

private void ContextMenu_Popup(object sender, System.EventArgs e)
{
	TreeNode node = TreeView.GetNodeAt(PointToClient(Cursor.Position)) as TreeNode;
	if (node == null)
		return;

	ContextMenu.MenuItems.Clear();
	ContextMenu.MenuItems.Add(node.Text);
}


When right clicking on a node this pops up the context menu but the node that it displays is (on my app) 80 pixels lower.

On looking through the forums I see that people tend to use something more like this:

private void TreeView_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
   	if (e.Button == MouseButtons.Right)
	{
		TreeNode node = TreeView.GetNodeAt(e.X, e.Y) as TreeNode;
		if (node == null)
			return;

		ContextMenu.MenuItems.Clear();
		ContextMenu.MenuItems.Add(node.Text);
	}
}


My questions is why even have a ContextMenu property if it does not work. I am probably just missing something obvious. But thanks anyway to any who reply.

Sean
AnswerRe: Why is there a ContextMenu Property on TreeView? Pin
SeanCM11-Nov-05 8:46
SeanCM11-Nov-05 8:46 
AnswerRe: Why is there a ContextMenu Property on TreeView? Pin
Colin Angus Mackay11-Nov-05 23:38
Colin Angus Mackay11-Nov-05 23:38 
GeneralRe: Why is there a ContextMenu Property on TreeView? Pin
SeanCM14-Nov-05 6:33
SeanCM14-Nov-05 6:33 
Questionsidebar Pin
faviochilo11-Nov-05 8:26
faviochilo11-Nov-05 8:26 
AnswerRe: sidebar Pin
leppie11-Nov-05 10:55
leppie11-Nov-05 10:55 
QuestionCreating a popup from Pin
naglbitur11-Nov-05 7:28
naglbitur11-Nov-05 7:28 
AnswerRe: Creating a popup from Pin
Wjousts11-Nov-05 7:55
Wjousts11-Nov-05 7:55 
GeneralRe: Creating a popup from Pin
naglbitur11-Nov-05 9:36
naglbitur11-Nov-05 9:36 
GeneralRe: Creating a popup from Pin
Wjousts11-Nov-05 10:59
Wjousts11-Nov-05 10:59 
Questionsend webcam stream over tcp ip Pin
toan198111-Nov-05 7:15
toan198111-Nov-05 7:15 
QuestionEventInfo.GetRaiseMethod() - anyone made it work? Pin
vSoares11-Nov-05 6:37
professionalvSoares11-Nov-05 6:37 
AnswerRe: EventInfo.GetRaiseMethod() - anyone made it work? Pin
leppie11-Nov-05 7:07
leppie11-Nov-05 7:07 
QuestionCreating Quick Launch like Applications Pin
jgallen2311-Nov-05 5:54
jgallen2311-Nov-05 5:54 
AnswerRe: Creating Quick Launch like Applications Pin
Dwayner7911-Nov-05 8:22
Dwayner7911-Nov-05 8:22 
GeneralRe: Creating Quick Launch like Applications Pin
Colin Angus Mackay12-Nov-05 3:27
Colin Angus Mackay12-Nov-05 3:27 
GeneralRe: Creating Quick Launch like Applications Pin
jgallen2313-Nov-05 18:19
jgallen2313-Nov-05 18:19 
QuestionDumping the DataGrid into a txt file Pin
zaboboa11-Nov-05 5:29
zaboboa11-Nov-05 5:29 

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.