Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

DataGridView get/set scrollbar position

$
0
0
Hey, so I've searched around and found different answers to this problem but none of em are perfect. I need to be able to get and set the horizontal scrollbar position so that I can get it before I refresh my dataGridView and set it afterwards. The closest I've found is dgv.FirstDisplayedScrollingColumnIndex, but to get it perfect you also need to store dgv.FirstDisplayedScrollingColumnHiddenWidth. The problem is that FirstDisplayedScrollingColumnHiddenWidth can't be set.

This would be much easier if I could just grab scrollbar.Position and then set it after, anyone know if there's a better way to do this?

Edit: to clarify on the two fields I'm trying to use, FirstDisplayedScrollingColumnIndex is the index of the leftmost column that's visible. FirstDisplayedScrollingColumnHiddenWidth is the width of the part of that cell that's hidden offscreen.

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>