The easiest way I see to explain what I need is via example.
Suppose I have a DataGridView with 20 rows of data. The DGV is sized to show 10 rows at a time. It is scrolled to show rows 4-13. Row 7 is selected. What I need is a way to get that Row7 is the 4th displayed row.
You can loop through all the DataGridViewRows in a DGV and check each Row’s
Displayedproperty. When you find the first one’s that’s true, that’s your first displayed row. Continue looping and checking the Row’sSelectedproperty.Here’s some test code:
As a bonus, you can check the Displayed property of the 7th row to make sure the user didn’t do anything crazy like size the DGV to stop displaying it.