Solved

Create a TreeList Programmatically

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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.   …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

11 Experts available now in Live!

Get 1:1 Help Now