0

Hi,

I have creatd a custom lisview. I have subscribed to some of its event like MouseDown, DoubleClick.
I want to explicitely unsubcribe it. I know GC will automatically do it but still i want to
do it explicitely.

Which is the best way to do this ?? Shall I implement dispose pattern to it ??
Please see my code below for reference.

/// <summary>
    /// Summary description for Grid.
    /// </summary>
    public sealed class MyCustomListView : ListView 
    {
        public PresetGrid()
        {
            // ... related codes

        // Want to unsubscribe this ??
                        MouseDown += OnMouseDown;
            DoubleClick += OnDoubleClick;

        }

        public  void OnDoubleClick(object sender, EventArgs e)
        {
            // .. related codes
        }

        public void GridMouseDown(object sender, MouseEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            // .. related codes
        }

   }

Thanks a lot.

2
Contributors
1
Reply
5
Views
4 Years
Discussion Span
Last Post by tinstaafl
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.