Click here to Skip to main content
15,892,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: Bind Binary data to Gridview Pin
SatyaKeerthi1529-Jul-10 23:55
SatyaKeerthi1529-Jul-10 23:55 
QuestionPublishing Update problem Pin
kbalias29-Jul-10 19:40
kbalias29-Jul-10 19:40 
AnswerRe: Publishing Update problem Pin
Richard MacCutchan29-Jul-10 22:36
mveRichard MacCutchan29-Jul-10 22:36 
QuestionHow to add multiple components (texboxes,compoboxbutton etc...) to a listview Pin
aneesh kumar k29-Jul-10 18:32
aneesh kumar k29-Jul-10 18:32 
AnswerRe: How to add multiple components (texboxes,compoboxbutton etc...) to a listview Pin
Mycroft Holmes29-Jul-10 20:55
professionalMycroft Holmes29-Jul-10 20:55 
AnswerRe: How to add multiple components (texboxes,compoboxbutton etc...) to a listview Pin
Gonzalo Cao29-Jul-10 23:53
Gonzalo Cao29-Jul-10 23:53 
QuestionToggling UI Elements (ToolStrip and MenuStrip Items and the Like) Pin
Matt U.29-Jul-10 16:53
Matt U.29-Jul-10 16:53 
AnswerRe: Toggling UI Elements (ToolStrip and MenuStrip Items and the Like) Pin
Jimmanuel30-Jul-10 3:31
Jimmanuel30-Jul-10 3:31 
Using a switch or creating a different method for each node are valid ways to do it.

My preferred method in this case would be to use the Tag property of each TreeNode to store a List of ToolStripItems that should be enabled when that node is selected. When the nodes are created (or in the form constructor, whichever is applicable) initialize the Lists. Then in the selection change handler disable everything, then cycle through the list of ToolStripItems for the selected node and re-enable each one.

Like this:
internal MyConstructor()
{
	// init the list of items for root node 1
	List<ToolStripItem> items = new List<ToolStripItem>();
	items.Add(newItemButton);
	items.Add(editButton);
	// add the rest of the items that should be enabled
	rootNode1.Tag = items;
	
	// init the list of items for root node 2
	items = new List<ToolStripItem>();
	items.Add(deleteItemButton);
	items.Add(crashTheComputerButton);
	// add the rest of the items that should be enabled
	rootNode2.Tag = items;
	
	// init the list of items for etc
	// . . .
}

private void mainTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{
	if (mainTreeView.SelectedNode == null) return;    // No selection

	TreeNode selectedNode = mainTreeView.SelectedNode;

	foreach(ToolStripItem item in /* the entire collection of toggle-able ToolStripItems */)
	{
		item.Enabled = false;
	}
	
	List<ToolStripItem> applicableItems = selectedNode.Tag as List<ToolStripItem>;
	if (applicableItems == null)
	{
		return;
	}
	
	foreach(ToolStripItem item in applicableItems)
	{
		item.Enabled = true;
	}
}

Badger | [badger,badger,badger,badger...]

GeneralRe: Toggling UI Elements (ToolStrip and MenuStrip Items and the Like) Pin
Matt U.30-Jul-10 8:42
Matt U.30-Jul-10 8:42 
GeneralRe: Toggling UI Elements (ToolStrip and MenuStrip Items and the Like) Pin
Matt U.30-Jul-10 12:03
Matt U.30-Jul-10 12:03 
GeneralRe: Toggling UI Elements (ToolStrip and MenuStrip Items and the Like) Pin
Jimmanuel31-Jul-10 6:39
Jimmanuel31-Jul-10 6:39 
QuestionNHibernate CreateSqlQuery and addEntity Pin
Matt Cavanagh29-Jul-10 16:22
Matt Cavanagh29-Jul-10 16:22 
QuestionUsing RasGetEntryProperties in .NET CF Pin
notsotragichero29-Jul-10 9:49
notsotragichero29-Jul-10 9:49 
QuestiondatagridView1_CellContentClick Problem Pin
MumbleB29-Jul-10 6:27
MumbleB29-Jul-10 6:27 
AnswerRe: datagridView1_CellContentClick Problem Pin
I Believe In GOD29-Jul-10 6:56
I Believe In GOD29-Jul-10 6:56 
GeneralRe: datagridView1_CellContentClick Problem Pin
MumbleB29-Jul-10 7:05
MumbleB29-Jul-10 7:05 
AnswerRe: datagridView1_CellContentClick Problem Pin
Mycroft Holmes29-Jul-10 17:21
professionalMycroft Holmes29-Jul-10 17:21 
GeneralRe: datagridView1_CellContentClick Problem Pin
MumbleB4-Aug-10 2:39
MumbleB4-Aug-10 2:39 
QuestionProblem with pc to pc Voice chat on LAN using h323 protocol. Pin
88Rocker29-Jul-10 5:46
88Rocker29-Jul-10 5:46 
AnswerReason for my vote of 1 Pin
OriginalGriff29-Jul-10 6:04
mveOriginalGriff29-Jul-10 6:04 
QuestionGive .NET Compiled Assemblly DLL StrongName Pin
I Believe In GOD29-Jul-10 5:33
I Believe In GOD29-Jul-10 5:33 
AnswerRe: Give .NET Compiled Assemblly DLL StrongName Pin
Ennis Ray Lynch, Jr.29-Jul-10 5:35
Ennis Ray Lynch, Jr.29-Jul-10 5:35 
GeneralRe: Give .NET Compiled Assemblly DLL StrongName Pin
I Believe In GOD29-Jul-10 5:54
I Believe In GOD29-Jul-10 5:54 
GeneralRe: Give .NET Compiled Assemblly DLL StrongName PinPopular
Nagy Vilmos29-Jul-10 5:59
professionalNagy Vilmos29-Jul-10 5:59 
GeneralRe: Give .NET Compiled Assemblly DLL StrongName Pin
I Believe In GOD29-Jul-10 6:02
I Believe In GOD29-Jul-10 6:02 

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.