Q:

ClickedCell DataGridView shouldn't work for column header

I have a DataGridView and it has 4 columns. I use the event CellClick so that when user clicks on the row, then it will be removed from DataGridView. Everything works fine, but when user by mistake click on the column header(name of the column) then the CellClick event appears and of course program crashes because i'm trying to remove a row and user clicked on the column header. Can I do something with that? Is there any property to disable possibility of clicking on the column header?

A:

In the CellClick event check e.RowIndex, it will be -1 if clicking a column header, and you can ignore it.
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) {
        if (e.RowIndex >= 0) {
            // they clicked a row..
        }
    }

