Question Treeview Nodes Alignment problem with Arial Font

suniligate

Member
Joined
Aug 11, 2010
Messages
10
Programming Experience
1-3
I am Using Treeview in my application.i am adding nodes at run time (only parent nodes no sub nodes).Treeview Font is Arial .

the problem with Alignment of nodes.These nodes are not properly aligning.

i wrote the following code in button click event

TreeView2.Nodes.Add("Node1 sdfsf BJKBb bsasb SDSD Sss" & " " & "1234-5678")
TreeView2.Nodes.Add("Nodesdsds sdfdsf XVf fd asdd dfdf" & " " & "1234-5678")
TreeView2.Nodes.Add("Node1dfdf fdf sdfff 77 gfhgfhgGG" & " " & "1234-5678")
TreeView2.Nodes.Add("Node dff fSDDSDDFSFF fdf SSSS1dff" & " " & "1234-5678")
even the Lenth of text of node is same for every node the alignment is not perfect.When i used courier new Font the alignment is perfect.

How to achive this alginment with Arial Font ?
 
If you want text of equal number of chars to appear same length (align char by char) you have to use a monospace font such as Courier New, Arial is not such a font.

For the record, the nodes themselves are of course perfectly aligned in the tree no matter which font :)
 
Thanks for ur reply
We suggested Courier new font to our client but he strictly wants Arial font and with perfect alignment!
U said like "For the record, the nodes themselves are of course perfectly aligned in the tree no matter which font"
But this is not the case.It is not perfectly aligned.Do we need to set any property in Treeview for Perfect alignment?
 
I distinguish between the nodes and the node text. Nodes are left aligned according to their level in tree. Your inquiry is about the node text, not the nodes. The only way to align node text (per char length) is to use a monospace font.
 
I will give the screenshots which will give u a clear idea of my problem

in VB they are using SSTreeview.so even they are using Arial font the alignment is perfect....chek the screen shot here
VB6_SSTreeView.JPG

in .NET we are using Treeview with same arial font.see the alignement here
DotNet_TreeView.JPG
 
i am adding each and evry node at run time and padding some vbTab's in VB.
the same thing i am doing in .NET.but see the alignment there.pretty bad.
my requirement is now to achive the perfect alignemnt of node text with arial font.
but in arial font "NODE1" and "node1" widths are not same.

i tried with drawnode event but i am ended up with Performance :(
Looking for better solution
 
To format multiple string values to a single string with column like alignment it is possible to use String.Format function, but without using a monospace font there is no way for these "columns" to appear aligned. As you mention, custom painting would be required.

I don't see any tree like structure in your view, perhaps you should use a tabular control like ListView or DataGridView instead?
 
perhaps you should use a tabular control like ListView or DataGridView instead //

I tried This ListView too.but unfortunately i am not able to achive tooltiptext there.See the tooltiptext image for a treeviewnode in screenshot.If one node is hided it will show us the tooltip like below.but in Listview Tooltip wil come into picture if any of the columns are not fully visible.it will show tooltip text for each cell .is there any way to get a row is fully visible or not in ListView(Details mode).so that i can write my logic to achive this tooltip text
 

Attachments

  • Treeview_ToolTip.JPG
    Treeview_ToolTip.JPG
    20.9 KB · Views: 29
For ListView you can turn on ShowItemTooltips. DataGridView show cell tooltips by default, controllable also with ShowCellToolTips.
 
For ListView you can turn on ShowItemTooltips. DataGridView show cell tooltips by default, controllable also with ShowCellToolTips. //
Yes i did the same thing
ShowToolTips = true for Listview
and i have 3 columns in my listview.the showtooltips will show the tooltips when the column is hided(Not fully visible).But i need the tooltip for entire row.like i shown in the above image.
when i assign the tooltiptext to a listview Item like ListView1.Items(0).ToolTipText = "Show ToolTip text" it wil show the tooltip even the the first row is fully visible.
i want to show the tooltip in only case the Row is not fully visible
Is there any work around to know a Full row in a listview is completely visible or not?
 
I think that kind of customization will be a struggle, no matter which direction you go.
 
Back
Top