how to disable datagridview mouse click event for headers in c# -


I am trying to get value from the DataGrid view on mouse click event.

Works great if I do not click in the data grid view, I get an error saying this:

  The index was outside of the non-negative and Must be less than the size of the collection. The name of the parameter:   

I use this code to locate the mouse click:

  Private Zero Datagram View 1_CellMouseClick (Object Sender, Data Grid ViewMobileAvenEventErgusE) {if (DataGridView1.Rows [E.Rindex] .index! = -1) {Textbox 1 text = DataGrid viu1. ROS [E. ROExX]. Seals [0]. Value Toasting (); } Other {textBox1.Text = ""; }}   

"DataGride View 1.RO [E. Randex] .index! = -1" does not work and I do not know why.

There will be no easy solution to disable the mouse click on the header! Thanks!

I also use it:

  dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;   

The entire column and cell content does not work to select. If I'm lucky, CEllContentClick works 3/10 times

try to write this instead.

  Private zero dataGridView1_CellMouseClick (Object Sender, DataGridViewCellMouseEventArgsE) {if (e.RowIndex! = -1) {textBox1.Text = dataGridView1.Rows [e.RowIndex] .cs [0] Value.ToString (); } Other {textBox1.Text = ""; }}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -