What's the reason?

Anonymous
2021-11-02T05:14:26.497+00:00

Q1. Why use "+ =" ?

Student_dataListView.CellClick += Student_dataListView_CellClick;

Q2. How to do if I want to check a mouse DoubleClick rather then a CellClick?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,992 questions
No comments
{count} votes

Accepted answer
  1. Jack J Jun 19,296 Reputation points Microsoft Employee
    2021-11-02T06:31:58.82+00:00

    @Anonymous , Welcome to Microsoft Q&A,

    Q1. Why use "+ =" ?

    The CellClick is an event, which is a special delegate. We could use '+=' to subscribe to events, you could refer to the Microsoft doc How to subscribe to and unsubscribe from events to know more about it.

    Q2. How to do if I want to check a mouse DoubleClick rather then a CellClick?

    We could use the following code to subscribe to the correspond events.

     public Form1()  
            {  
                InitializeComponent();  
                dataGridView1.CellClick += DataGridView1_CellClick;  
                dataGridView1.MouseDoubleClick += DataGridView1_MouseDoubleClick;  
            }  
    
            private void DataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)  
            {  
                // Do Something  
            }  
    

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    No comments

0 additional answers

Sort by: Most helpful