DatagridView AutoResizeRows

0
0

I noticed that AutoResizeRows is considering the columns with visible=false. Is this a bug or I did something wrong?

  • You must to post comments
0
0

Questions:

  1. Does version 2.1.80 include the correct resizeRows patch? If yes, can I remove the patch from my project?
  2. The patch provided seems to ignore the first row when switching back to wrapmode=false. It’s still a bug?
  • Luca (ITG)
    I don’t see any issue with the first row. The data in your test has lots of new lines in the first row.
  • Adrian Zagar
    You are right! Sorry for confusion. Any info about 2.1.80 regarding resizeRows?
  • You must to post comments
0
0

Thanks for the modified sample. You are a very good teacher. And a quick one!

  • Wrong patch still had an error.
    With the new patch it’s working excellent. And I’d learned how to include a patch 🙂
  • The sample code set the DataSource to null before changing the WrapMode on the columns, but there are zero columns when removing the data source
    I (wrongly) presumed that DefaultCellStyle is considered just when the Datadrid is filled.
  • Both buttons set WrapMode to True
    In the real project it was correct. Damn copy-paste bug 🙂
  • No need to remove the data source
    Again: I (wrongly) presumed that DefaultCellStyle is considered just when the Datadrid is filled. And I’m still using that for quick resize columns. My way is still (many times) faster than AutoResizeColumns provided by wisej. If you want to develop this aspect, I’m always available.
  • No need to set the size in the Shown event, you can anchor right and bottom
    Thank you. I never thought I can use more than one corner!
  • If you set AllowHtml = true on the columns it will render the html in the cells (screenshot)
    Thank you again. In the real project I have tinyEditor for html column, and unfortunately not all values are html. Can the datagrid make distinction between html/non-html values? What if I allow inline editing for html values?
  • Luca (ITG)
    Thanks. When AllowHtml is true it simply means that Wisej will not escape the text and the browser is able to render the html as-is. If your cell text is test when editing you will see “test”. You can set a custom html editor on any cell or column setting the DataGridViewColumn.Editor property. The cell style is a inherited all the way up (cell, column, row, grid). In your sample the column loop never started because there are no columns, You can set the cell styles globally for the grid using datagrid1.DefaultCellStyle.
  • You must to post comments
0
0

Thanks for the sample. See attached. And sorry for the wrong patch, these are the issues (some unrelated to the autosizing of the rows):

  • Wrong patch still had an error.
  • The sample code set the DataSource to null before changing the WrapMode on the columns, but there are zero columns when removing the data source
  • Both buttons set WrapMode to True
  • No need to remove the data source
  • No need to set the size in the Shown event, you can anchor right and bottom
  • If you set AllowHtml = true on the columns it will render the html in the cells (screenshot)

The attached adjusted sample includes the latest fix (is in the dev. build)  so you can also see how to include bundled js with your app.

Video:

https://drive.google.com/file/d/1Q94V4deU14D2_BKEEch3ONuxq55IMCCV/view

  • You must to post comments
0
0

I attached a small project, maibe it will be easier to tell what I’m doing wrong. You’ll have to add nugget Newtonsoft.Json because I can’t upload more than 3.9M…

Thank you,

Adrian

Attachment
  • You must to post comments
0
0

Still not seems to work in 2.1.78

Can you give me a working sample of a filled datagrid that adapt row height (and wrap content) by code?

Thank you,

Adrian

  • You must to post comments
0
0

Hi Adrian,

it´s fixed in Wisej development build 2.1.78 that has just been released.

Best regards
Frank

  • You must to post comments
0
0

Try the attached patch. Put in /Platforms or /Resources and set to Embedded Resource in AssemblyInfo uncomment the WisejResource attribute.

  • Adrian Zagar
    Please give me more details on how to do that. I never tried something like that. When do you expect a new dev release?
  • You must to post comments
0
0

There is a regression in the javascript. Will fix in a dev build. I’m not sure I can have a patch before then.

  • You must to post comments
0
0

I tried on 2.1.77. You have here a sample of code. Until 2.1.76 (included) that code works weird because of (sometimes big) not visible columns. Now it’s not working at all. I mean, nothing happens when I run that code with wrapText true/false.

Can you give me a working sample of a filled datagrid that adapt row height (and wrap content) by code?

Thank you,

Adrian

 

public static void AutoSizeTable(ref DataGridView dg, autoSizeTableMode tip, bool? wrapText = false)
{
try
{
var ds = dg.DataSource;
dg.DataSource = null;
switch (tip)
{
//bla-bla…
case autoSizeTableMode.Equal://user defined mode

for (int i = 0,nr_visible=0; i < dg.ColumnCount; i++,nr_visible+=((dg.Columns[i].Visible)?1:0));
for (int i = 0; i < dg.ColumnCount; i++)
dg.Columns[i].Width = dg.Width / nr_visible;
break;
//bla-bla…
default:
break;
}
if (wrapText != null)
for (int i = 0; i < dg.ColumnCount; i++)
dg.Columns[i].DefaultCellStyle.WrapMode = ((bool)wrapText ? DataGridViewTriState.True : DataGridViewTriState.False);
dg.DataSource = ds;
if (wrapText != null) dg.AutoResizeRows();
}
catch (Exception ex)
{
//bla-bla…
}
}

  • You must to post comments
0
0

Hi Adrian,

issue #2324 is fixed in Wisej release 2.1.77

Best regards
Frank

  • You must to post comments
0
0

Hi Adrian,

Thanks for reporting. It’s a bug! I’ve logged it as #2324 and a fix will be available in the next build!

Best,

Levie

  • You must to post comments
Showing 11 results
Your Answer

Please first to submit.