on-internet
← Community

How to check if column header is clicked in datagridview using SelectionChanged event

Stack Overflow ·

I'm using SelectionChanged event of a DataGridView. I have a code that will display the value of a DataGridView's cell to a TextBox. However, when I click the column header, this also triggers the code (I assume because of the SelectionChanged event) and will display an error. What I want to achieve is to enclose my codes in the datagridview1_SelectionChanged in an if statement. Wherein: if(column header is clicked) //don't do anything` else //do the display of data to textbox` I just want to know the code for checking if you clicked a header or not.

Comments

Sign in or sign up to comment and upvote.

No comments yet.