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

Issue with SelectedItemChanged event

1 Answer 332 Views
ListView
This is a migrated thread and some comments may be shown as answers.
George C.
Top achievements
Rank 2
Iron
Veteran
George C. asked on 23 Mar 2020, 12:50 PM

Greetings,

I accidentally noticed an issue while working with RadlistView.

"SelectedItemChanged" event is supposed to be fired when Item Changing of RadlistView is done ("SelectedItemChanged" must be fired after "SelectedItemChanging"), But it is as if "SelectedItemChanged"  acts just like the "SelectedItemChanging" event.

I attached a picture that illustrates a simple test. I'm wondering why it raises error. There were 5 items in the list and even if there is no item that is already selected ( I do not mean Current Item), it should select an item as user clicks on an item, then after finishing selecting ("SelectedItemChanging") the item, it should fire  "SelectedItemChanged" event.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Mar 2020, 02:34 PM
Hello, George,

Note that the SelectedItemChanged event is expected to be fired when the SelectedItem gets changed. It also can be null when there is no SelectedItem in RadListView at a certain moment. That is why before accessing the SelectedItem in the event handler it is necessary to check for null value before that:
        private void RadListView1_SelectedItemChanged(object sender, EventArgs e)
        {
            if (this.radListView1.SelectedItem!=null)
            {
                Console.WriteLine(this.radListView1.SelectedItem.Text);
            }
        }
I hope this information helps. If you need any further assistance please don't hesitate to contact

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ListView
Asked by
George C.
Top achievements
Rank 2
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or