views:

232

answers:

3

We've used the DataGridView extensively in our client. Our customers want to be able to enter large amounts of text into a row - too much to be displayed in the height of the DataGridView - and scroll through them using the main scrollbar - i.e. the DataGridView's scrollbar.

However, the DataGridView will only scroll such that a row is snapped to the top of the control; if a row is larger than the DataGridView then you can only ever see the top of it.

How do I make a DataGridView that doesn't snap its rows to the top of the control?

+1  A: 

The basic answer is that you can't. The DataGridView paints itself by determining the current top row and then painting that top row into the upper left-hand corner, and then continuing on down (you can see this by using Reflector to look at the PaintRows method of the DataGridView).

Instead of trying to scroll the whole row, why not use an auto-sizing textbox? It will increase its height as the user types, and they can scroll the textbox itself.

+1  A: 

have you checked "DataRepeater" control that comes under visual basic Power Packs 3.0; it can be very handy in your scenario.

Video Tutorial:
http://windowsclient.net/learn/video.aspx?v=30534

Download Link:
http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx

Asad Malik
A: 

Put the DataGridView in a Panel control and make the Panel scrollable. Make sure the DataGridView's Dock is set to none and the Height is set to the sum of the heights of the rows in the grid.

mhenry1384
yes, this is pretty much how I did end up working round the problem. It doesn't work with virtual mode, though.
Simon