Click here to Skip to main content
16,016,623 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help with Windows services Pin
quilkin9-Jun-04 5:49
quilkin9-Jun-04 5:49 
GeneralListbox not refreshing. Pin
shadow_nubcake8-Jun-04 11:28
shadow_nubcake8-Jun-04 11:28 
Generalevent not picked up by form Pin
RomanD8-Jun-04 10:16
RomanD8-Jun-04 10:16 
GeneralRe: event not picked up by form Pin
Heath Stewart8-Jun-04 11:35
protectorHeath Stewart8-Jun-04 11:35 
GeneralRe: event not picked up by form Pin
RomanD8-Jun-04 12:09
RomanD8-Jun-04 12:09 
QuestionHow do I lock and Unlock files Pin
silverbullet8-Jun-04 8:32
silverbullet8-Jun-04 8:32 
AnswerRe: How do I lock and Unlock files Pin
Heath Stewart8-Jun-04 8:43
protectorHeath Stewart8-Jun-04 8:43 
GeneralTreeView context Menu C# Windows Forms Pin
OMalleyW8-Jun-04 8:27
OMalleyW8-Jun-04 8:27 
I am using a Context Menu on a treeview and needed to get a reference to the treenode that was selected, it is all done in the MouseUp method
Here is my code

<br />
		private void TreeView1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
		{<br />
			if (e.Button.ToString().ToUpper() == "RIGHT")<br />
			{<br />
				this.TreeView1.ContextMenu.Show(this.TreeView1,new Point(e.X,e.Y));<br />
				this.TreeView1.SelectedNode = (this.TreeView1.GetNodeAt(e.X,e.Y));<br />
				this.TreeView1.SelectedNode.BackColor = Color.FromName("HighLight");<br />
				this.TreeView1.SelectedNode.ForeColor = Color.White;<br />
				//<br />
                                MessageBox.Show(this.TreeView1.SelectedNode.Text);<br />
<br />
--------------------------------------------------------------------------<br />
ADDED <br />
A better way to do this....<br />
<br />
                               this.TreeView1.ContextMenu.Show(this.TreeView1,new Point(e.X,e.Y));<br />
                               this.TreeView1.GetNodeAt(e.X,e.Y).BackColor = Color.FromName("HighLight");<br />
 	                       this.TreeView1.GetNodeAt(e.X,e.Y).ForeColor = Color.White;<br />
			       //<br />
                               MessageBox.Show(this.TreeView1.GetNodeAt(e.X,e.Y).Text);<br />
<br />
			}			<br />
		}<br />
--------------------------------------------------------------------------------<br />
<br />


I just ran into a situation where I had to get e reference to a TreeNode when a user right clicked a node.

You do not need to set the ContextMenu property of the treeview to get the ContextMenu to show up.
this.treeViewContextMenu.Show(this.TreeView1,new Point(e.X,e.Y));


Well I just thought that I would post this. Let me know what you thinkBig Grin | :-D
William O'Malley
GeneralRe: TreeView context Menu C# Windows Forms Pin
bneacetp8-Jun-04 15:42
bneacetp8-Jun-04 15:42 
GeneralListView Scrollbars disappear Pin
Guinness4Strength8-Jun-04 7:59
Guinness4Strength8-Jun-04 7:59 
GeneralRe: ListView Scrollbars disappear Pin
Guinness4Strength8-Jun-04 10:35
Guinness4Strength8-Jun-04 10:35 
GeneralRe: ListView Scrollbars disappear Pin
Heath Stewart8-Jun-04 11:29
protectorHeath Stewart8-Jun-04 11:29 
GeneralRe: ListView Scrollbars disappear Pin
Guinness4Strength9-Jun-04 5:03
Guinness4Strength9-Jun-04 5:03 
GeneralLooping through all controls on a webform Pin
caheo8-Jun-04 7:29
caheo8-Jun-04 7:29 
GeneralRe: Looping through all controls on a webform Pin
Colin Angus Mackay8-Jun-04 7:50
Colin Angus Mackay8-Jun-04 7:50 
GeneralRe: Looping through all controls on a webform Pin
caheo8-Jun-04 8:12
caheo8-Jun-04 8:12 
GeneralRe: Looping through all controls on a webform Pin
Colin Angus Mackay8-Jun-04 8:22
Colin Angus Mackay8-Jun-04 8:22 
GeneralRe: Looping through all controls on a webform Pin
Heath Stewart8-Jun-04 8:41
protectorHeath Stewart8-Jun-04 8:41 
GeneralRe: Looping through all controls on a webform Pin
Dave Kreskowiak8-Jun-04 7:56
mveDave Kreskowiak8-Jun-04 7:56 
GeneralRe: Looping through all controls on a webform Pin
Heath Stewart8-Jun-04 8:18
protectorHeath Stewart8-Jun-04 8:18 
GeneralRe: Looping through all controls on a webform Pin
Dave Kreskowiak8-Jun-04 8:47
mveDave Kreskowiak8-Jun-04 8:47 
GeneralRe: Looping through all controls on a webform Pin
Heath Stewart8-Jun-04 8:48
protectorHeath Stewart8-Jun-04 8:48 
GeneralRe: Looping through all controls on a webform Pin
Andy Brummer8-Jun-04 8:40
sitebuilderAndy Brummer8-Jun-04 8:40 
GeneralPeriod key in numpad Pin
machocr8-Jun-04 5:34
machocr8-Jun-04 5:34 
GeneralRe: Period key in numpad Pin
Heath Stewart8-Jun-04 5:45
protectorHeath Stewart8-Jun-04 5:45 

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.