Padding in treeview

Posted on 2008-11-13
Last Modified: 2012-05-05
I'm populating a treeview from a datatable.  I can create all the nodes I want OK but I'm having trouble with the formatting.  Can anyone explain why the following does not give equal "columns" :

oNode.Nodes.Add(oRow(0).ToString.PadRight(20) & oRow(1).ToString.PadRight(50) & _
                            oRow(2).ToString.PadLeft(10) & oRow(3).ToString.PadLeft(10) & _

Question by:Petermcg001
    LVL 44

    Accepted Solution

    Hello Petermcg001,

    Probably because you are using proportional fonts. To have equal columns with this method you must use non-proportional fonts such as courier where each character takes up the same width regardless. Normal proportional fonts allow differing characters to take up different amounts of space in order to read more naturally but therefore do not align when padded like this.


    LVL 1

    Author Comment

    Thanks Tim

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now