Search code examples
winformsdevexpressxtratreelist

Problem with image column in XtraTreeList


I use XtraTreeList control.

There are 2 columns: first for text and second for icon

Problem : I can't change default icon (zero index in corresponding imagelist). There are 3 images in imagelist.

For example I need to show icon which is located at 2 index

Code

 TreeListColumn col = treeList1.Columns.Add();
            col.Caption = "Text";
            col.Visible = true;

            TreeListColumn colImage = treeList1.Columns.Add();
            colImage.Caption = "ImageColumn";
            colImage.Visible = true;


            RepositoryItemImageEdit imageEdit = new RepositoryItemImageEdit();
            imageEdit.Images = imageList;

            treeList1.RepositoryItems.Add(imageEdit);
            colImage.ColumnEdit = imageEdit;

            treeList1.BeginUnboundLoad();

            TreeListNode node = treeList1.AppendNode(new object[] { "trololo", 2}, null);

            node.SetValue(colImage.AbsoluteIndex, 2);

            treeList1.EndUnboundLoad();

Solution

  • Thanks for everybody

    Using RepositoryItemPictureEdit solved my problem. A little bit complex, but works

     TreeListColumn col = treeList1.Columns.Add();
                col.Caption = "Text";
                col.Visible = true;
    
                TreeListColumn colImage = treeList1.Columns.Add();
                colImage.Caption = "ImageColumn";
                colImage.Visible = true;
    
                RepositoryItemPictureEdit imageEdit = new RepositoryItemPictureEdit();
                imageEdit.ShowMenu = false;
    
                treeList1.RepositoryItems.Add(imageEdit);
                colImage.ColumnEdit = imageEdit;
    
                treeList1.BeginUnboundLoad();
    
                Image img = imageList.Images[1];
                Bitmap bmp = new Bitmap(img);
    
                TreeListNode node = treeList1.AppendNode(new object[] { "trololo", bmp }, null);
    
    
                treeList1.EndUnboundLoad();