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

Custom Items and Grouping

2 Answers 128 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 17 Apr 2012, 05:43 PM
Hello, I went through and created a custom visual item for my listview and everything worked out great (Telerik documentation was a big help). I then tried to apply custom grouping to my listview and no grouping appeard (everything loads, just without groups). After another quick look I realized that my custom item is also being applied to the group item (doh!). How would I go about determining the type of item being created int the VisualItemCreating event? Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 20 Apr 2012, 03:36 PM
Hello Hunter,

Thank you for writing.

The event arguments of the VisualItemCreating event contain the original visual item that will be used if you do not replace it. You can test its type to determine whether it is a group item or a regular item. The following code snippet demonstrates this:
void radListView1_VisualItemCreating(object sender, ListViewVisualItemCreatingEventArgs e)
{
    if (e.VisualItem is BaseListViewGroupVisualItem)
    {
        //creating group
    }
    else
    {
        //creating item
    }
}

I hope this will help you. Should you have any additional questions, do not hesitate to contact us.

All the best,
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
Hunter
Top achievements
Rank 1
answered on 20 Apr 2012, 04:56 PM
That's what I needed. Thank you :)
Tags
ListView
Asked by
Hunter
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Hunter
Top achievements
Rank 1
Share this question
or