This is a migrated thread and some comments may be shown as answers.

Problems with visualizing subitems

2 Answers 143 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 03 Feb 2012, 06:26 PM
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 Answers, 1 is accepted

Sort by
0
Dennis
Top achievements
Rank 1
answered on 05 Feb 2012, 07:28 PM
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);
0
Boryana
Telerik team
answered on 07 Feb 2012, 02:16 PM
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 >>
Tags
ListView
Asked by
Dennis
Top achievements
Rank 1
Answers by
Dennis
Top achievements
Rank 1
Boryana
Telerik team
Share this question
or