简体   繁体   中英

DatagridView cell click event in visual c#

I am learning Windows Visual C# so I am new to this. I have this code for the cell click event for my DataGridView

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
      con.  ID = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
      txtname.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
      txtlname.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
    }

The question is: Even how many times I click my DataGridView it's not firing my breakpoint. How to solve this?

Like this,

You can reach properties by right clicking or pressing F4 after selecting datagridview .

在此处输入图片说明

After press lightining icon and double click to event that you like to handle.

在此处输入图片说明

Finally you will see this,

在此处输入图片说明

Hope helps,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM