Solved

Create a TreeList Programmatically

Posted on 2008-10-15
1
6,550 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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