Menu

AutoSize Column

Help
TGK
2006-10-04
2013-04-23
  • TGK

    TGK - 2006-10-04

    Having trouble auto sizing a column.  Probably doing it wrong. 
    --------------------------------------------

    grid1.Columns[0].AutoSizeMode = AutoSizeMode.EnableAutoSize;

    ... then I populate the rows followed by ...

    grid1.Columns.AutoSizeColumn(0);

    Thanks!

     
    • Davide Icardi

      Davide Icardi - 2006-10-04

      Do you receive an error or a wrong result?

      Can you try to explain the problem with a more extended description?

      Davide

       
      • TGK

        TGK - 2006-10-04

        Davide,

        Consider this example:

                    grid1.BorderStyle = BorderStyle.FixedSingle;
                    grid1.ColumnsCount = 2;
                    grid1.FixedColumns = 1;
                    grid1.FixedRows = 1;

                    grid1.Rows.Insert(0);
                    grid1[0, 0] = new SourceGrid.Cells.Cell("colHeader1");
                    grid1[0, 1] = new SourceGrid.Cells.Cell("colHeader2");

                    grid1.Rows.Insert(1);
                    grid1[1, 0] = new SourceGrid.Cells.Cell("rowHeader1");
                    grid1[1, 1] = new SourceGrid.Cells.Cell("cellValue1");

                    grid1.Rows.Insert(1);
                    grid1[2, 0] = new SourceGrid.Cells.Cell("rowHeader2");
                    grid1[2, 1] = new SourceGrid.Cells.Cell("cellValue2");

                    grid1.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize;
                    grid1.Columns.AutoSizeColumn(0);

        The results seems to actually make column 0 smaller instead of increasing it to fit the text.

         
        • Davide Icardi

          Davide Icardi - 2006-10-04

          You are right. There is a bug in the AutoSize method. I open a bug report and I will try to fix it soon.

          Thanks

          Davide

           
    • Davide Icardi

      Davide Icardi - 2006-10-08

      I think to have solved this bug in the new version that I have just released (4.0.0.2).

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.