Click here to Skip to main content
15,889,403 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to set textbox1.text in one form from other forms ? Pin
DigitalKing7-Feb-06 15:28
DigitalKing7-Feb-06 15:28 
GeneralRe: how to set textbox1.text in one form from other forms ? Pin
hdv2127-Feb-06 17:22
hdv2127-Feb-06 17:22 
GeneralRe: how to set textbox1.text in one form from other forms ? Pin
DigitalKing7-Feb-06 20:14
DigitalKing7-Feb-06 20:14 
Questionupdate problem Pin
Ado_bado7-Feb-06 11:22
Ado_bado7-Feb-06 11:22 
QuestionDatagrid Context Menu Pin
OrbeaOrca7-Feb-06 10:11
OrbeaOrca7-Feb-06 10:11 
QuestionSendMessage problems Pin
sowhatman007-Feb-06 9:21
sowhatman007-Feb-06 9:21 
AnswerRe: SendMessage problems Pin
sowhatman007-Feb-06 23:54
sowhatman007-Feb-06 23:54 
QuestionCan't get "TreeNodeCollection.Contains" to validate node Pin
JstDaNuGuy7-Feb-06 9:15
JstDaNuGuy7-Feb-06 9:15 
Trying to combine dbRecords that overlap to display as one unit on treeView.
so rather than looking like:

+ dept1<br />
+ dept2<br />
+ dept2<br />
+ dept2<br />
+ dept3<br />
+ dept3<br />
+ dept4


I want it to look like:

+ dept1<br />
+ dept2<br />
+ dept3<br />
+ dept4


Using TreeNodeCollection.Contains Method to acheive this goal, but its not working. It seems that becuase i'm recreating the TreeNode object [TreeNode myNode = new TreeNode()] on each new loop it doesn't have anyway to refrenece the data i've already written. This makes sense, but it seems odd that i can't refrence the pre-written data inside of the tree.

I've tried refrenceing the actual TreeView, (tView.Nodes.Contains(myNode)
I've tried the locally written TreeNode (DeptNode.Nodes.Contains(myNode)
I've tried doing a foreach loop[foreach(TreeNode node in tView.Nodes)] and checking doing if(node.Tag == myNode.Tag)
I've tried removing the recreation of the TreeNode so it refrences the same node object when doing the search
(i only ended up with the expected result of only adding the newest node to the TreeView rather than several new nodes)

and pretty much i'm at wits end on what would work...

Here's the code:

private void TelList()
		{
			statusBarPanel1.Text = "Please Wait While We Update the List";
			
			PhoneTree.Nodes.Clear();
			TreeNode ParentNode = new TreeNode("Phone List");
			TreeNode Purge = new TreeNode("Purge");
			PhoneTree.Nodes.Add(ParentNode);
			PhoneTree.Nodes.Add(Purge);


			while (TreeRead.Read())
			{
				TreeNode DeptNode = new TreeNode();
				TreeNode TelNode = new TreeNode();
				TreeNode ModNode = new TreeNode();
				DeptNode.Text = TreeRead.GetString(7);
				DeptNode.Tag = TreeRead.GetValue(4);
				ModNode.Text = TreeRead.GetString(2);
				ModNode.Tag = TreeRead.GetValue(4);
				TelNode.Text = TreeRead.GetString(3);
				TelNode.Tag = TreeRead.GetValue(2);
				if (ParentNode.Nodes.Contains(DeptNode))
					{				
						if (ModNode.Tag == DeptNode.Tag)
						{
							if (DeptNode.Nodes.Contains(ModNode))
							{
								if (ModNode.Nodes.Contains(TelNode))
								{continue;}
								else
								{
									ModNode.Nodes.Add(TelNode);
								}
							}
							else
							{
								DeptNode.Nodes.Add(ModNode);
							}

						}
						if (TelNode.Tag.ToString() == ModNode.Text)
						{
							ModNode.Nodes.Add(TelNode);
						}
					

					}
					else
					{
						ParentNode.Nodes.Add(DeptNode);					
						if (ModNode.Tag == DeptNode.Tag)
						{
							
							if (DeptNode.Nodes.Contains(ModNode))
							{
								ModNode.Nodes.Add(TelNode);
							}
							else
							{
								DeptNode.Nodes.Add(ModNode);
							}

						}
						if (TelNode.Tag.ToString() == ModNode.Text)
						{
							ModNode.Nodes.Add(TelNode);
						}
					
						
					}
				}
			
			TreeRead.Close();
			TreeConn.Close();
}


Big Grin | :-D Laugh | :laugh: Poke tongue | ;-P Sniff | :^) Sigh | :sigh:
AnswerCan a guy get some help over here??? Pin
JstDaNuGuy8-Feb-06 4:41
JstDaNuGuy8-Feb-06 4:41 
QuestionGroupbox border color Pin
VPMahank7-Feb-06 8:53
VPMahank7-Feb-06 8:53 
AnswerRe: Groupbox border color Pin
DigitalKing7-Feb-06 15:32
DigitalKing7-Feb-06 15:32 
QuestionCustom Object that has 'nested' collections Pin
kloepper7-Feb-06 8:52
kloepper7-Feb-06 8:52 
AnswerRe: Custom Object that has 'nested' collections Pin
Guffa7-Feb-06 9:16
Guffa7-Feb-06 9:16 
GeneralRe: Custom Object that has 'nested' collections Pin
kloepper7-Feb-06 9:46
kloepper7-Feb-06 9:46 
AnswerRe: Custom Object that has 'nested' collections Pin
Guffa7-Feb-06 10:56
Guffa7-Feb-06 10:56 
QuestionInclude files Pin
dvsr7-Feb-06 8:51
dvsr7-Feb-06 8:51 
AnswerRe: Include files Pin
Guffa7-Feb-06 9:21
Guffa7-Feb-06 9:21 
GeneralRe: Include files Pin
dvsr8-Feb-06 4:43
dvsr8-Feb-06 4:43 
AnswerRe: Include files Pin
Guffa8-Feb-06 6:07
Guffa8-Feb-06 6:07 
QuestionHRESULT E_FAIL Error? Pin
Mertli Ozgur Nevres7-Feb-06 6:36
Mertli Ozgur Nevres7-Feb-06 6:36 
AnswerRe: HRESULT E_FAIL Error? Pin
Dave Kreskowiak7-Feb-06 7:01
mveDave Kreskowiak7-Feb-06 7:01 
GeneralRe: HRESULT E_FAIL Error? Pin
Mertli Ozgur Nevres8-Feb-06 1:05
Mertli Ozgur Nevres8-Feb-06 1:05 
GeneralRe: HRESULT E_FAIL Error? Pin
Dave Kreskowiak8-Feb-06 2:01
mveDave Kreskowiak8-Feb-06 2:01 
GeneralRe: HRESULT E_FAIL Error? Pin
Mertli Ozgur Nevres8-Feb-06 22:46
Mertli Ozgur Nevres8-Feb-06 22:46 
GeneralRe: HRESULT E_FAIL Error? Pin
Dave Kreskowiak9-Feb-06 3:07
mveDave Kreskowiak9-Feb-06 3:07 

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.