Go Premium for a chance to win a PS4. Enter to Win


How can I create 3 columns in a TreeView in VB6?

Posted on 2006-06-28
Medium Priority
Last Modified: 2012-05-05
I would like to create 3 columns in a TreeView, where all the rows are Left justified one below the other, and the following is the sample code I used:

Set nodx = TreeView1.Nodes.Add(nodr, tvwChild, , "Rs.Name" & vbTab & "Rs.date" & vbTab & "Rs.Amount")

The vbTab is not good, because it returns a character that is from a different language. To put in spaces will not either be good, because the rows will not be properly aligned.

Please advise me how to work around this.
Thank you.
Yom Tov Succos
Question by:YomTovSuccos
  • 3
  • 2
  • 2

Expert Comment

ID: 17006877
Can u please explain a good reason why u want to use TreeView for this instead of using ListView or ms flex grid if u want hierarchical view of items ?

u can create as much columns as u want in ListView. TreeView, by it's nature, doesn't support columns. do the following for list view

    Dim lvwli As ListItem
    With ListView1
        .View = lvwReport
        With .ColumnHeaders
            .Add , "colName", "Name"
            .Add , "colDate", "Date"
            .Add , "colAmt", "Amount"
        End With
        Set lvwli = .ListItems.Add(, , "My Name")
        lvwli.SubItems(1) = "A Date"
        lvwli.SubItems(2) = "An Amount"
    End With

if u want hierarchical view, create a custom disconnected recordset with the hierarchy u want and bind it with a flex grid. it is much more powerful. if u want help on creating hierarchical disconnected recordset, lemme know.

Expert Comment

ID: 17007037
well, kaliyug ka arjun, aapka theer acha hei.  that's a good one but not stable as i used it before.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 17007424
Well..if u want then u can try this freeware

ActiveX tree control 3.12.65 from this link..


Author Comment

ID: 17012557
Can u please explain a good reason why u want to use TreeView for this

I Need to use
nodx.Expanded = True

nodx.Expanded = False

Accepted Solution

gafoorgk earned 2000 total points
ID: 17013377
in that case it's better to use msflex grid with disconnected hierarchical recordset as it'll give powerful control over UI.

Author Comment

ID: 17018958
Iil use VsFlex Grid Thanks A Milion

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

885 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