I have a DataGridView control in a TabPage, and I listen for the SelectionChanged event. When the TabPage is selected, the DataGridView selects the first row and fires the SelectionChanged event. How can I stop it from automatically selecting a row?
C# – How to stop a DataGridView from automatically selecting a row
.netc++datagridview
Related Question
- C# – How to update the GUI from another thread
- C# – How to remedy “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning
- C# – How to Sort a List
by a property in the object - C# – Prevent selecting cell in DataGridView
- C# – Datagridview SelectionChanged event based on row selection
- C# – Why not inherit from List
Best Solution
I can think of two ways of working around this, If you know the event always fires, Have a bool flag that is set on the first selection, then only perform the rest of your SelectionChanged code.
The other way is to have a hidden control that is the first TabStop for the TabPage and hence is the first control to get focus (I say this without having tested any this of course, just my two cents).