Columns.Clear() and flickering

Help
2007-01-21
2013-04-23
  • Nobody/Anonymous

    Hello,

    I found a problem with flickering cells when using column.clear() and rowspan (at least I think it's the rowspan's fault, only the cells of the rowspan flicker). Here some code to reproduce it:

    private void createTimeTable() {
                grid1.ColumnsCount = 3;

                grid1.Rows.Insert(0);
                grid1.Rows.Insert(1);

                grid1[0, 0] = new SourceGrid.Cells.Cell("RowSpan");
                grid1[0, 0].RowSpan = 2;

                grid1[0, 1] = new SourceGrid.Cells.Cell("ColSpan");
                grid1[0, 1].ColumnSpan = 2;

                grid1[1, 1] = new SourceGrid.Cells.Cell("Cell");
                grid1[1, 2] = new SourceGrid.Cells.Cell("Cell");
    }

    private void form_Load(object sender, EventArgs e)
            {
                createTimeTable();          
            }

    private void button_Click(object sender, EventArgs e)
            {
                grid1.Columns.Clear();
                createTimeTable();
            }

    When the button is clicked, the grid should be rebuilt (of course in a simple example like that I could use invalidate, but in my real world project the timetable is created with other parameters). What is even more strange than the flickering, is that the grid starts to grow in height...

    Regards,
    Anna

     
    • Davide Icardi

      Davide Icardi - 2007-01-21

      Hi,

      Sorry but I can't reproduce this problem (flickering or grow height).

      I have also created with this code (a modified version of your code to create more cells):

              private void createTimeTable()
              {
                  grid1.ColumnsCount = 30;

                  for (int r = 0; r < 100; r += 2)
                  {
                      grid1.Rows.Insert(0);
                      grid1.Rows.Insert(1);

                      for (int c = 0; c < 30; c += 3)
                      {
                          grid1[0, c] = new SourceGrid.Cells.Cell("RowSpan");
                          grid1[0, c].RowSpan = 2;

                          grid1[0, c+1] = new SourceGrid.Cells.Cell("ColSpan");
                          grid1[0, c+1].ColumnSpan = 2;

                          grid1[1, c+1] = new SourceGrid.Cells.Cell("Cell");
                          grid1[1, c+2] = new SourceGrid.Cells.Cell("Cell");
                      }
                  }
              }

              private void form_Load(object sender, EventArgs e)
              {
                  createTimeTable();
              }

              private void button1_Click(object sender, EventArgs e)
              {
                  grid1.Columns.Clear();
                  createTimeTable();

              }

      The performance are not optimal but seems to work well.

      Are you sure that the problem is not with other code? Or a different configuration?

      Davide

       
    • Nobody/Anonymous

      Hello Davide,

      I'm very sorry, I really forgot the important part: it's the fixed rows/columns together with row span.
      The grid settings are just the default settings when I put it on the form in the designer, they look like this:
                  //
                  // grid1
                  //
                  this.grid1.Location = new System.Drawing.Point(48, 29);
                  this.grid1.Name = "grid1";
                  this.grid1.Size = new System.Drawing.Size(151, 126);
                  this.grid1.StyleGrid = null;
                  this.grid1.TabIndex = 1;

              private void createTimeTable()
              {
                  grid1.ColumnsCount = 3;
                  grid1.FixedRows = 2;
                  grid1.FixedColumns = 1;

                  grid1.Rows.Insert(0);
                  grid1.Rows.Insert(1);

                  grid1[0, 0] = new SourceGrid.Cells.Cell("RowSpan");
                  grid1[0, 0].RowSpan = 2;

                  grid1[0, 1] = new SourceGrid.Cells.Cell("ColSpan");
                  grid1[0, 1].ColumnSpan = 2;

                  grid1[1, 1] = new SourceGrid.Cells.Cell("Cell");
                  grid1[1, 2] = new SourceGrid.Cells.Cell("Cell");
              }

      For this code I can see for a short moment that the grid is drawn shifted by about one column to the left. So the "ColSpan" text appears/disappears in the first column. But even without the fixed rows/columns the height growing happens. You just need to click on the button several times... If you still cannot see anything, I will send you the whole code of the designer + my form code.

      Regards,
      Anna

       
      • Davide Icardi

        Davide Icardi - 2007-01-23

        The problem of the growing is simply because you don't reset the RowsCount.
        Try for example to clear the grid adding
        grid.Redim(0,0)
        just before
        grid1.ColumnsCount = 3

        For the flickering problem I think that you can try to Redim the grid only if required. Try with this code:
        <code>

                private void createTimeTable()
                {
                    grid1.FixedRows = 2;
                    grid1.FixedColumns = 1;

                    grid1[0, 0] = new SourceGrid.Cells.Cell("RowSpan");
                    grid1[0, 0].RowSpan = 2;

                    grid1[0, 1] = new SourceGrid.Cells.Cell("ColSpan");
                    grid1[0, 1].ColumnSpan = 2;

                    grid1[1, 1] = new SourceGrid.Cells.Cell("Cell");
                    grid1[1, 2] = new SourceGrid.Cells.Cell("Cell");
                }

                private void button1_Click(object sender, EventArgs e)
                {
                    createTimeTable();
                }

                private void Form1_Load(object sender, EventArgs e)
                {
                    grid1.Redim(2, 3);

                    createTimeTable();
                }
        </code>

        Basically I redim the grid only in the form_load

        Davide

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks