[WinForms] Displaying a hidden DataGridView column’s data in a textbox, when the row is clicked on.

I have a DataGridView with 7 columns. I only show 6 of those columns, and hide the 'notes' column. When I click on a row of data, I would like the value of the hidden 'notes' column to appear in a textbox on my form.

The code I currently have is:

notesDisplayTextbox.Text = dataGridView1.CurrentRow.Cells["notes"].Value.ToString(); 

The odd thing is that this will work, albeit sporadically. Some cells I click on will display that row's 'notes' value, and then clicking on a different cell in another row will not alter the notesDisplayTextbox's text at all.

Any help is appreciated.

by Rogue_Grogan via /r/csharp

Leave a Reply