Home - Forums-.NET - FlyGrid.Net (Windows Forms) - SmartFit Bug

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

SmartFit Bug
Link Posted: 24-Mar-2006 07:04
Hi,

here's another problem I have with SmartFit. Look at the video I made:
http://www.kingvest.de/qb.wmv

You see that the first column only resizes when the 2nd row is added and a value is entered. Why is not resized as soon as the value is entered into the 1st cell? 1st column is SmartFit, all others FitMode.Spring

Thanks,

Tom
Link Posted: 27-Mar-2006 09:50
Here's another video that shows this bug:

http://www.kingvest.de/bugs/sizing2/sizing2.html
Link Posted: 30-Mar-2006 12:26
The problem shown in [http://www.kingvest.de/qb.wmv] is solved.
About the [http://www.kingvest.de/bugs/sizing2/sizing2.html] - I'll try to describe:
The sample that demonstrates ways of node additions described below you can download here
There are three ways to add node:
[c#] 1.More Optimal
private void button1_Click(object sender, System.EventArgs e)
{
  object[] data = new object[]{
                                    rnd.Next(1000) > rnd.Next(1000),//size
                                    string.Format("(KLAC) KCQ; DK{0:F} Call", rnd.Next(1000)/6),//strike
                                    string.Empty,//lots
                                    decimal.Round(decimal.Remainder(1, (decimal)rnd.NextDouble()), 2),//bid
                                    decimal.Round(decimal.Remainder(1, (decimal)rnd.NextDouble()), 2),//ask
  };
  this.performanceGrid.Rows.Items.Add(new Node(data));      
}


[c#] 2. Less Optimal
private void button3_Click(object sender, System.EventArgs e)
{
  Node newNode = new Node(new object[performanceGrid.Columns.VisibleColumns.Length]);
  this.performanceGrid.Rows.Items.Add(newNode);
  for(int i=0; i < performanceGrid.Columns.VisibleColumns.Length; i++)
  {
    object cellValue = null;
    switch(i)
    {
      case 0:
        cellValue = rnd.Next(1000) > rnd.Next(1000);//size
        break;
      case 1:
        cellValue = string.Format("(KLAC) KCQ; DK{0:F} Call", rnd.Next(1000)/6);//strike
        break;
      case 2:
        cellValue = string.Empty;//lots
        break;
      case 3:
      case 4:
        cellValue = decimal.Round(decimal.Remainder(1, (decimal)rnd.NextDouble()), 2);//bid/ask
        break;
    }
    //in this case column automatically recalculates width
    performanceGrid.Columns.VisibleColumns[i].SetValue(newNode, cellValue);
  }
}


[c#] 3. Minimally Optimal for autocalculations - need to use BeginInit/EndInit to force calculations
private void button3_Click(object sender, System.EventArgs e)
{
  Node newNode = new Node(new object[performanceGrid.Columns.VisibleColumns.Length]);
  this.performanceGrid.Rows.Items.Add(newNode);
  for(int i=0; i < performanceGrid.Columns.VisibleColumns.Length; i++)
  {
    object cellValue = null;
    switch(i)
    {
      case 0:
        cellValue = rnd.Next(1000) > rnd.Next(1000);//size
        break;
      case 1:
        cellValue = string.Format("(KLAC) KCQ; DK{0:F} Call", rnd.Next(1000)/6);//strike
        break;
      case 2:
        cellValue = string.Empty;//lots
        break;
      case 3:
      case 4:
        cellValue = decimal.Round(decimal.Remainder(1, (decimal)rnd.NextDouble()), 2);//bid/ask
        break;
    }
    newNode.SetCellValue(this.performanceGrid.Columns.VisibleColumns[i], cellValue);        
  }
}


As you can see - you can use more optimal ways to add node without BeginInit/EndInit usage or use BeginInit/EndInit to force recalculations.
NB: The 2. Example related to the [http://www.kingvest.de/qb.wmv] and will work correctly with nearest update.
Link Posted: 20-Apr-2006 21:21
Given that, what is the very fastest way to set cell values?
I'm usually doing node[colIndex] = value;
I'd like to have as little overhead as possible when doing this... however, with that I have this never ending problem that my cells are invalidated only occasionally if I don't force invalidation
Link Posted: 23-Apr-2006 10:12
Yes,
node[colIndex] = value
is fastest method.
this method automatically fires internal OnChanged event that fires cell invalidation.