Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

treeview nodes are not refreshing

Status
Not open for further replies.

dmsruthi

Programmer
Aug 17, 2005
19
US
Hi,
am working on TreeView, I edited node text and I am concatinating some text to edited text, but its not reflecting on treeview i.e treeview is not refreshing.

I am concatinating text in afterlabeledit event.


I would appreciated if anyone post the solution

Thanks
 
I'm not sure I entirely understand your problem. Can you post some code?
 
Hi thanks for the quick reply,


e.Node.Text=" ("+ area.Count+") "+e.Label;

here I am concatinating extra text to the node, but its now showing on next


here is my code.


///////////////////////////////////////////////////////
private void conferenceTreeView1_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
{
if (e.Label != null)
{
if(e.Label.Length > 0)
{
if (e.Label.IndexOfAny(new char[]{'@', '.', ',', '!'}) == -1)
{
e.Node.EndEdit(false);
AbstractArea area = (AbstractArea)e.Node.Tag;
object e.Node.Text=" ("+ area.Count+") "+e.Label;
}
else
{
/* Cancel the label edit action, inform the user, and
place the node in edit mode again. */
e.CancelEdit = true; e.Node.BeginEdit();
}
}
else
{
/* Cancel the label edit action, inform the user, and
place the node in edit mode again. */
e.CancelEdit = true;
e.Node.EndEdit(true);
}
this.conferenceTreeView1.BeginLabelEdit = false;
}

}

//////////////////////////////////////

Thanks
 
This doesn't make sense.

if (e.Label.IndexOfAny(new char[]{'@', '.', ',', '!'}) == -1)

That if statement will be true if one of the items is found, yet, you cancel the edit. Why?


Also: You might want to look at regular expressions. I assume you're trying to pull an email? create an email regex.

 
I am not allowing any special characters in node text.

thats different scenario,

but my treeview is not refreshing, I am explicitly changing node text, but its not appearing on treeview


Thanks
 
Your code didn't compile. This code now works for me and my tree view.

Code:
private void treeView1_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
		{
			if (e.Label != null)
			{
				if(e.Label.Trim().Length > 0)
				{
					if (e.Label.IndexOfAny(new char[]{'@', '.', ',', '!'}) == -1)
					{   
						//The label does not contain any of the bad characters
						e.Node.EndEdit(false);
						//AbstractArea area = (AbstractArea)e.Node.Tag;
						//e.Node.Text=" ("+ area.Count+") "+e.Label;    
					}
					else
					{
						//The label contains one of the bad characters
						e.CancelEdit = true;                                    
						e.Node.BeginEdit();
					}
				}
				else
				{
					//The Label does not contain any text and is not just spaces.
					e.CancelEdit = true;
					e.Node.EndEdit(true);
				}
				
			}
		}
 
hey here I am adding some extra text but its not appearing on node

AbstractArea area = (AbstractArea)e.Node.Tag;
e.Node.Text=" ("+ area.Count+") "+e.Label;

Thanks
 
thats a special class,
forget about that

e.Node.Text="SOME EXRTRA TEXT"+ e.Label;

I think now u r clear :)

Thanks


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top