Problems with visualizing subitems

3 posts, 0 answers
  1. Dennis
    Dennis avatar
    7 posts
    Member since:
    Aug 2011

    Posted 03 Feb 2012 Link to this post

    Hello together,

    I'm having some difficulties with a RadListView. My RadListView has 3 Columns: 1 for displaying an icon, 1 for a filename and the third for the author.
    My problem is, that only the first column is displayed and all the text columns are empty. I don't know why. Perhaps someone of you can help. Here is the code:

    ImageList MyImageList = new System.Windows.Forms.ImageList();
           
    MyImageList.Images.Add(global::Test_SharePoint_DocumentList.Properties.Resources.icgen);
     
    MyImageList.ImageSize = new Size(16, 16);
     
    lst_Files.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
    lst_Files.ShowGridLines = true;
    lst_Files.FullRowSelect = true;
    lst_Files.Columns.Add("File","File");
    lst_Files.Columns.Add("Filename", "Filename");
    lst_Files.Columns.Add("Author", "Author");
    lst_Files.Columns[0].Width = 30;
    lst_Files.SmallImageList = MyImageList;
     
    foreach(Microsoft.SharePoint.SPFile file in files)
    {
      for (int j = 0; j < MyImageList.Images.Count; j++)
      {
        Telerik.WinControls.UI.ListViewDataItem item2 = new Telerik.WinControls.UI.ListViewDataItem();
        item2.Image = global::Test_SharePoint_DocumentList.Properties.Resources.icgen;
        item2.ImageIndex = j;
        item2.Tag = mysite.Url + "/" + file.Name;
     
        Telerik.WinControls.UI.ListViewDataItem item3 = new Telerik.WinControls.UI.ListViewDataItem();
        item3.Text = file.Name;
        item3.Value = file.Name;
     
        Telerik.WinControls.UI.ListViewDataItem item4 = new Telerik.WinControls.UI.ListViewDataItem();
        item4.Text = file.Author.ToString();
        item4.Value = file.Author.ToString();
     
        Telerik.WinControls.UI.ListViewSubDataItemCollection subcol = new Telerik.WinControls.UI.ListViewSubDataItemCollection(item2);
        subcol.Add(item3);
        subcol.Add(item4);
     
        lst_Files.Items.Add(item2);
      }
      Count++;
    }

    And that's how it looks like in debug (see attachment):


  2. Dennis
    Dennis avatar
    7 posts
    Member since:
    Aug 2011

    Posted 05 Feb 2012 Link to this post

    I have solved this issue.
    Here is my new code:

    var itemName = String.Format("listItem{0}", counter++);
    var values = new string[] { "", file.Name, file.Author.ToString() };
    var item2 = new Telerik.WinControls.UI.ListViewDataItem(itemName, values) { Image = global::Test_SharePoint_DocumentList.Properties.Resources.icgen, ImageIndex = j, Tag = mysite.Url + "/" + file.Name };
    lst_Files.Items.Add(item2);
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 07 Feb 2012 Link to this post

    Hello Dennis,

    Thank you for writing.

    I am glad you managed to solve the issue. In case you need assistance, do not hesitate to contact us.

    Greetings,
    Boryana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top