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

Binding troubles

3 Answers 121 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Alessio
Top achievements
Rank 1
Alessio asked on 02 Apr 2012, 10:36 AM
I tried to follow your guide, but I'm not able to figure out what step I skipped... 
The problem is that when I group my items, they all get into a single group with the FQDN of the object in BindingList. For the same reason (I think), the ordering doesn't work.

I set up a RadListView whith those parameters (ViewType cannot be changed):
radListView1.DataSource = dtoList;
oDtoList = dtoList;
radListView1.DisplayMember = "Title";
radListView1.ValueMember = "PictureId";
radListView1.ViewType = ListViewType.IconsView;
radListView1.Padding = new Padding(10, 48, 10, 10);
this.radListView1.ItemSize = new Size(300, 110);
this.radListView1.ItemSpacing = 5;
this.radListView1.AllowArbitraryItemHeight = false;

dtoList is a BindingList of:
public class DTOimage
    {
       public Int64 PictureId;
       public String Path;
       public String Author;
       public String Title;
       public DTOimage(){}
       public DTOimage(Int64 pictureId, String path, String author, String title)
       {
           PictureId = pictureId;
           Path = path;
           Author = author;
           Title = title;
       }
    }

when I group items, I've:
private void commandBarDropDownList2_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            this.radListView1.GroupDescriptors.Clear();
            switch (this.commandBarDropDownList2.Text)
            {
                case "Nessuno":
                    this.radListView1.EnableGrouping = false;
                    this.radListView1.ShowGroups = false;
                    break;
                case "Nome":
                    this.radListView1.GroupDescriptors.Add(new GroupDescriptor(
                        new SortDescriptor[] { new SortDescriptor("Title", ListSortDirection.Ascending) }));
                    this.radListView1.EnableGrouping = true;
                    this.radListView1.ShowGroups = true;
                    break;
                case "Autore":
                    this.radListView1.GroupDescriptors.Add(new GroupDescriptor(
                        new SortDescriptor[] { new SortDescriptor("Author", ListSortDirection.Ascending) }));
                    this.radListView1.EnableGrouping = true;
                    this.radListView1.ShowGroups = true;
                    break;
            }
        }

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 04 Apr 2012, 09:13 AM
Hi Alessio,

Thank you for writing.

The observed behavior is caused by the fact that your data class does not have public properties, but public fields. If you change the definition of your DTOimage class as shown below, you should get this scenario working as expected:
public class DTOimage
{
    public Int64 PictureId { get; set; }
    public String Path { get; set; }
    public String Author { get; set; }
    public String Title { get; set; }
    public DTOimage() { }
    public DTOimage(Int64 pictureId, String path, String author, String title)
    {
        PictureId = pictureId;
        Path = path;
        Author = author;
        Title = title;
    }
}

The reason for this is that the data layer over which RadListView is built, takes into consideration only the public properties and not the fields. The same data layer is used in RadGridView and RadTreeView so this is also relevant for these controls.

I hope this helps. Feel free to ask if you have any additional questions.

Kind regards,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Alessio
Top achievements
Rank 1
answered on 04 Apr 2012, 10:10 AM
Whoa... Easy as you said, thank you.
0
Nikolay
Telerik team
answered on 04 Apr 2012, 10:21 AM
Hi Alessio,

You are welcome. Let us know if you have additional questions.

Greetings,
Nikolay
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
ListView
Asked by
Alessio
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Alessio
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or