From: lord.zoltar on
I have a DataGridView that has potentially several hundred rows
(possibly a thousand or two).
I'd like for each row to have the proper height to accomadate the text
in the row. I tried setting the AutoSizeRowMode to AllCells. This
worked great on small datasets, but the program hung for a long time on
larger datasets.

I changed it to DisplayedCells, but this has some quirks: All of the
initally displayed rows are the correct height (for the text they
contain), but when I scroll, all other rows are about 1 line of text
tall (but most cells in fact contain up to 3 lines of text).
I can get the displayed cells to adjust to the correct height, but only
if I make some other change to the datagrid, such as adjusting the
column width. This event seems to force an autoresize. Unfortunately,
I'd rather have an an autoresize take place when I scroll.
I added the following code to the scroll even handler:

Me.searchResult_Grid.AutoResizeRows(DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders)

But it doesn't seem to have an effect.

Actually, I'd rather have the autoresize when I STOP scrolling, but
"If e.Type = ScrollEventType.EndScroll Then" doesn't seem to do
anything.

Another problem I'm having with column sizing:
The client wants the columns to fit the data (shouldn't be too hard
with the proper AutosizeMode) but also wants to be able to manually
resize them. I just can't seem to get this to work. If I set the
columnAutosizeMode to initially be AllCells, then the column widths are
perfect, but the user cannot manually adjust. If I set it to None, then
the columns are all the same width, but the user CAN manually adjust.
Is it even possible to do this?

From: lord.zoltar on
Forget to mention:
with regards to the column resize problem, I DID set
allowUserToResizeColumns to True, but when AutoSizeColumnMode is set to
AllCells, I cannot actually resize the columns.

From: lord.zoltar on
I added this code to the scroll event handler:

If e.Type <> ScrollEventType.ThumbTrack AndAlso e.ScrollOrientation =
ScrollOrientation.VerticalScroll Then

Me.searchResult_Grid.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells)

End If

I came to it mostly by trial and error :S
It seems to work ok for what I need but still seems a bit hackish. Can
anyone out there offer more insight into DataGridView row and column
resizing?