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.

Something like this should work:

MouseDown -= OnMouseDown;
DoubleClick -= OnDoubleClick;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.