Solved

Create a TreeList Programmatically

Posted on 2008-10-15
1
6,582 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
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…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

732 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