Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

I am looking for a way to align the buttons in my treeview so that it will look like in the same column even if it is in any level. Eg:

Item1 [Button]
 Item2 [Button]
Item3[Button]

i want it to look like

Item1  [Button]
 Item2 [Button]
Item3  [Button]
Posted
Updated 19-Dec-11 5:45am
v2
Comments
Wendelius 19-Dec-11 11:45am    
Pre tags removed from normal text

Try by setting the minwidth on the treeview elements and then right align the buttons.
 
Share this answer
 
Comments
Member 8134835 20-Dec-11 4:50am    
i tried but its not working..
I won't advise you to do so. You could really invent some better UI design, really. The tree structure will be less visible, but what's more important, you will have a change to truncate a part of the item text; and it's pretty hard to adjust the room taken by the text on left and measure a left indent of a tree node to compensate in in a button position. I warned you; but still you can get an alignment you want.

The element of a TreeView can be a two-column one-line Grid with fixed-width left column. When you create a node during run-time, you read the level of the node and calculate required width of the left column.

To me, it looks like an excessive design annoying design which is not very easy to debug. Adding a deeper node can always break the picture.

You could do much better. For example, one button per a whole tree with action depending on selected node. How about that?

—SA
 
Share this answer
 
Comments
Prashant Srivastava LKO 19-Dec-11 13:03pm    
Is http://www.sakryukov.org is your website sir
thatraja 19-Dec-11 14:18pm    
Yes man
Member 8134835 20-Dec-11 0:54am    
SAKryukov but i want button for each tree node

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900