Solved

Create a TreeList Programmatically

Posted on 2008-10-15
1
6,508 Views
Last Modified: 2012-05-05
Hello,

I'm having a little trouble populating a DevExpress treelist (in vb.net 2005) that I created via code.  I can add it through the form design manually and it works fine.

However when I add it through code, it has no columns and no rows.  Likewise, the IsUnBoundMode shows True.  However, you can see that I assign a datasource.  This same datasource works fine when I add the treelist manually in form design.  So what am I doing wrong or what am I missing?

Please help.

Here is my code:

    Dim treelist2 As TreeList = New TreeList

            treelist2.Name = "TreeList2"
            treelist2.Dock = DockStyle.Fill
            treelist2.OptionsBehavior.PopulateServiceColumns = True
            treelist2.ParentFieldName = "fldcParentId"
            treelist2.KeyFieldName = "fldKeyId"
            treelist2.DataSource = dttHierDtl
            treelist2.SelectImageList = imgSmallIcon
            treelist2.StateImageList = imgSmallIcon

            treelist2.CustomizationFormBounds = TreeList1.CustomizationFormBounds
            treelist2.ImageIndexFieldName = "fldIconOpn"
            treelist2.PopulateColumns()
            treelist2.Visible = True
0
Comment
Question by:hi2way
1 Comment
 

Accepted Solution

by:
hi2way earned 0 total points
ID: 22729323
I figured it out.  There is one additional line of code (required to be the first row):

Me.Controls.Add(treelist4)
            treelist4.Name = "treelist4"
            treelist4.ParentFieldName = "fldcParentId"
            treelist4.KeyFieldName = "fldKeyId"
            treelist4.DataSource = dttHierDtl1
            treelist4.PopulateColumns()
            treelist4.Columns("fldTag").VisibleIndex = -1
            treelist4.Columns("fldKeyNm").OptionsColumn.AllowEdit = False
            treelist4.Columns("fldKeyNm").OptionsColumn.AllowFocus = False
            treelist4.OptionsSelection.EnableAppearanceFocusedCell = False
            treelist4.OptionsSelection.EnableAppearanceFocusedRow = False
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

22 Experts available now in Live!

Get 1:1 Help Now