Programmatically resize DataGridView to remove scroll bars

Viewed 8147

I have a DataGridView with a user definable number of columns (anywhere from ~6-60) of numerical data. At the higher end that amount of data in the grid exceeds that which can be displayed on screen at once. I have a graph that goes with the data. I would like to keep the two in sync, so that a specific time T on the graph is in line vertically with the same time in the grid.

To do this I'd like to make the DGV just wide enough to avoid a horizontal scroll bar, have the graph be equally wide, and then offload the scrolling onto a container control. However, I can't find a way to directly get the width I'd need to set the DGV to in order to remove the scroll bar from it.

2 Answers
Related