Variable size DataGridView rows

0
0

I’m having huge issues with DataGridView rows.
I have a field in my datagrid which can have a lot of content, so I want each row to be a different height which I’m achieving using:

myGrid.AutoResizeRows(5);

I call this after adding the rows to the table and inside and Application.Update block.

It kinda works, in that the rows all size sensibly to fit their contents, but I see 2 issues.

  1. It’s not entirely consistent. Scrolling down far enough I find rows that are of the standard height and have not resized to their contents
  2. The grid does not scroll to the bottom of the list, some fields are hidden off the bottom at the maximum scrollbar position.

Any thoughts ?
Am I missing some steps I need to perform to get this working correctly ?

Thanks,

Andi Gordon

  • You must to post comments
0
0

Hi Andi,

actually it´s not a bug but expected behavior:

The call dataGridView1.AutoResizeRow(rowid); inside your loop does not have any effect as the rows are not on the client yet.

In order to make your sample work you can either set the AutoSizeRowsMode

this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;

Here now further Resize call is needed.

Or you can set the BlockSize of the DataGridView higher because the resizing otherwise only applies to the client cache.

Best regards
Frank

  • You must to post comments
0
0

Hi Andi,

any chance to wrap up a test case for us?

Best regards
Frank

  • Andi Gordon
    HI, Sorry it took so long, I have reproduced part of the issue in a test case. https://www.dropbox.com/s/ip69tv5i3oltw60/Test%20Grid%20Sizing.zip?dl=0 In this case it only sizes the first few pages of data, the ones at the end are not sized to the contents. Additionally in our application the scrollbar does not scroll to the last row, but the list ends many rows before the last one and it is impossible to scroll any further. It is never the exact same amount either. Thanks, Andi
  • Frank (ITG)
    Hi Andi, thanks for providing the sample. It seems to work fine with the latest build. Can you please verify? TIA, Frank
  • Frank (ITG)
    Hi Andi, checking more closely we could reproduce. I´ll log that issue and keep you updated. Best regards, Frank
  • Andi Gordon
    Thank you.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.