I’m working on a project where I want to load information based on the selection in a dataGridView. I created a dataGridView in the designer of my form and I added this line:
this.dataGridView1.SelectionChanged += methodToBeCalled;
This all works fine, but I have one nasty problem. Most of the time when I start my application there’s nothing happening after selecting a row. Then, when I look in my code, the line of code has disappeared completely.
First I thought somebody committed some code over mine, but even when I don’t update it disappears.
What could be the reason (bug/visual studio design) for the disappearing code? How could I fix it?
You are placing it in the .designer.cs file correct? This is wrong. It has to be placed in your normal code behind screen. The .designer file can be re-generated whenever the system wants to.