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

Group can be selected

1 Answer 139 Views
ListView
This is a migrated thread and some comments may be shown as answers.
ZT885048
Top achievements
Rank 1
ZT885048 asked on 18 Apr 2012, 06:21 AM
Hello

I have my data added like this way Added for items and two groups and assigned as below.
this.radListView1.Groups.Add(new ListViewDataItemGroup("First Group"));
this.radListView1.Groups.Add(new ListViewDataItemGroup("Second Group"));
 
this.radListView1.Items[0].Group = this.radListView1.Groups[0];
this.radListView1.Items[1].Group = this.radListView1.Groups[0];
this.radListView1.Items[2].Group = this.radListView1.Groups[1];
this.radListView1.Items[3].Group = this.radListView1.Groups[1];
If I wanted to select the first Group "First Group" and on basis for that i wanted to show message or call any other event...
How can i do that ?

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Apr 2012, 03:36 PM
Hello,

Thank you for writing.

I am not quite sure that I understand your requirement, however, I assume that you want to detect when the user have clicked the group header, so you can perform some action. If this is so, you need to handle the MouseDown event of RadListView and check the clicked item type. Here is a sample:
void radListView1_MouseDown(object sender, MouseEventArgs e)
{
    SimpleListViewGroupVisualItem element = radListView1.ElementTree.GetElementAtPoint(e.Location) as SimpleListViewGroupVisualItem;
 
    if (element != null)
    {
        RadMessageBox.Show(element.Text + " clicked");
    }
}

If this is not the case, please provide me with additional details regarding the desired functionality.
 
Kind regards,
Stefan
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
ZT885048
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or