ListView dispose in Double Click

7 posts, 0 answers
  1. George
    George avatar
    11 posts
    Member since:
    Feb 2014

    Posted 03 Sep 2015 Link to this post

    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.

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 03 Sep 2015 Link to this post

    Hello George,

    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 disposed there will be no items and an exception will occur. Generally you should not manually dispose any controls or components. They will be disposed when their parent form is disposed. Detailed information is available here: c# - Winforms Disposing IDisposable.

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. George
    George avatar
    11 posts
    Member since:
    Feb 2014

    Posted 03 Sep 2015 Link to this post

    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.

     

  5. George
    George avatar
    11 posts
    Member since:
    Feb 2014

    Posted 03 Sep 2015 in reply to George Link to this post

    At the moment I am selecting the icon in the listview and press a button to set the Icon *
  6. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 04 Sep 2015 Link to this post

    Hi George,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. George
    George avatar
    11 posts
    Member since:
    Feb 2014

    Posted 07 Sep 2015 in reply to Dimitar Link to this post

    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.

  8. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 08 Sep 2015 Link to this post

    Hello George,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready