locked
AddHandler, RemoveHandler RRS feed

  • Question

  • I have a VB-Project where I deactivate (and later reactivate) the event CellEnter of DatagridView dgvBooks.

    Very simple using:

    RemoveHandler dgvBooks.CellEnter, AddressOf dgvBooks_CellEnter

    AddHandler dgvBooks.CellEnter, AddressOf dgvBooks_CellEnter

    BUT: in C# I can't find the relevant code ?!


    Friday, June 19, 2020 8:41 AM

All replies

  • Friday, June 19, 2020 8:46 AM
  • Hello,

    Here is a working example.  

    To create a new event handler, in a windows form, in the new constructor type Shown += followed by pressing TAB TAB to create the event.

    public MyForm()
    {
        InitializeComponent()
        Shown += (press [tab][tab])
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, June 19, 2020 9:53 AM
  • RemoveHandler dgvBooks.CellEnter, AddressOf dgvBooks_CellEnter

    AddHandler dgvBooks.CellEnter, AddressOf dgvBooks_CellEnter

    BUT: in C# I can't find the relevant code ?!

    In C# AddHandler and RemoveHandler are written as += and -= :

    dgvBooks.CellEnter -= dgvBooks_CellEnter;

    dgvBooks.CellEnter += dgvBooks_CellEnter;

    Friday, June 19, 2020 5:15 PM