问题
How can I prevent from clicking or selecting RowHeader
s?
I want that when a new user clicks on a row
or cell
, then move all information to an update Form
and it's working fine.
But, if a user clicks on a RowHeader
, then it should select all rows and generate an error.
I know I can hide RowHeader
s, but I want to show RowHeader
s and I want to prevent users from clicking on them.
I have used the SelectionMode
property of the DataGridview
and set it to CellSelect/FullRowSelect etc, but it did not help.
Is it possible to disable RowHeader
s and not let people select RowHeader
s?
Here is my code so far:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
decimal accNo = Convert.ToDecimal(dataGridView1.Rows[e.RowIndex].Cells[0].Value);
var item = db.UserAccount.Where(a => a.AccountNo == accNo).FirstOrDefault();
txtAccountNo.Text = item.AccountNo.ToString();
txtFirstName.Text = item.FirstName;
txtLastName.Text = item.LastName;
txtAddressUpNew.Text = item.Address.ToString();
}
来源:https://stackoverflow.com/questions/53233848/how-to-disable-rowheader-on-a-datagridview