Solved

Create a TreeList Programmatically

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

3 Use Cases for Connected Systems

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

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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