InnerXml in ToolTip

A

ALI-R

I am showing the InnerXml of a node (in a treeView Control) in a tooltip
,but it is not formatted well ,all the elements after each other ,is there a
way to format the innertext in a tooltip.

=========Code==========

private void tvTreeView_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e){
string strTemp="";
int i=0;
TreeNode tn = this.tvTreeView.GetNodeAt(e.X, e.Y);
if(tn !=null) {
int currentNodeIndex = tn.Index;
if (tn.Text !="subreport") return;
if(currentNodeIndex != oldNodeIndex){
oldNodeIndex = currentNodeIndex;
if(this.tooltipGeneral != null && this.tooltipGeneral.Active)
this.tooltipGeneral.Active = false; //turn it off
XmlDocument sourceDoc = new XmlDocument();
sourceDoc.Load(this.txtFilename.Text);
XmlNodeList subreportNodes = sourceDoc.DocumentElement.ChildNodes;
foreach (XmlNode subreportNode in subreportNodes)
{
if ( i==currentNodeIndex)
{
strTemp=subreportNode.InnerXml;
break;
}
}
else i++;
}
this.tooltipGeneral.SetToolTip(this.tvTreeView, strTemp);
this.tooltipGeneral.Active = true; //make it active so it can show
}
}
}
 
N

Nicholas Paldino [.NET/C# MVP]

ALI,

You would have to do the formatting yourself.

If you want to do some simple formatting, why not read the current
element, then increment an indent counter (which you keep yourself) when you
move to read the child nodes, and so on, and so on. Then, when done reading
the child nodes, you decrement the indent counter.

Then, you would write out the contents of the node (not the inner xml,
but the node itself), and then prefix the line with the a number of tabs
equal to the indent counter.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top