Hello,
I noticed that when I try to dispose a ListView control from its own double click event the application crashes.
The control can be disposed from any other source (e.g. a button click) and this behavior occurs even on an empty List View.
Am I doing something wrong or is this a bug?
Thanks.
6 Answers, 1 is accepted
Thank you for writing.
When the RadListView is double clicked, an item is selected. This happens when the mouse button is released (the MouseUp event) and if the control is there will be no items and an exception will occur. Generally you should not manually dispose any controls or components. They will be when their parent form is . Detailed information is available here: c# - Winforms Disposing IDisposable.
I hope this will be useful.
Regards,
Dimitar
Telerik
Hello and thanks for your reply.
I am trying to change the icon of a node in a treeview by opening a user control that contains a listview with icons.
This user control closes (with dispose) on deactivate event.
What I was trying to do is to select the icon with double click, do the appropriate actions for the selection and then close the user control.
At the moment I am selecting the icon in the listview and press a button to set the action and dispose the control.
Is there any way I can do it with double click?
Thanks.
Thank you for writing back.
As I have mentioned before you do not need to manually dispose the controls. Or at least you should do that when you are sure that the control is no longer needed (when the form is closed for example).
I hope this information helps.
Regards,
Dimitar
Telerik
Hello again.
Even if I am not disposing any control or form the same behavior occurs when I am trying to programmatically close a form.
This is the case:
Press a button, open a new form with a listview.
The listview has a double click event with Me.close.
When I double click the listview the program crashes.
I do not manually dispose anything.
How can I make this work?
Thanks.
Thank you for writing back.
I was able to reproduce the case where the exception occurs. It is happening because the item is retrieved when the MouseUp event occurs. Since it occurs after the DoubleClick event the item cannot be retrieved because the form is already closed. This is considered an issue and I have logged it in our Feedback Portal. You can track the item for status changes and add your vote for it here.
To workaround the issue you can use the ItemMouseDoubleClick event instead.
Your Telerik Points have been updated for this report.
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik