Home - Forums-.NET - FlyGrid.Net (Windows Forms) - adding items

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

adding items
Link Posted: 13-Mar-2006 00:19
hi,
first of all there is no proper documentation to this control.
and second
i'm using the flygrid as a simple grid (rows and column)
how do i add nodes dynamiclly to the grid .
and please make that code simple.

the out come i need is:
column 1 | column 2 | column...
cell 1,1    | cell 1,2   | cell 1,...
cell 2,1    | cell 2,2   | cell 2,...
cell 3,1    | cell 3,2   | cell 3,...
cell 4,1    | cell 4,2   | cell 4,...

thanks.
Link Posted: 13-Mar-2006 00:43
[c#]
private void InitFlyGrid(FlyGrid flyGrid)
{
  flyGrid.BeginInit();//freeze flyGrid updates
  try
  {
    //add columns to FlyGrid
    AddColumns(flyGrid);
    //add nodes an fill cells
    AddRows(flygrid);
  }
  finally
  {
    flyGrid.EndInit();//unfreeze and update flyGrid
  }
}

private void AddColumns(FlyGrid flyGrid)
{
  //clear existing columns
  flyGrid.Columns.Items.Clear();
  //create empty array of columns for addition to FlyGrid
  Column[] cols = new Column[3];
  for(int i=0; i < cols.Length; i++)
  {
    //create new column
    cols[i] = new Column("column " + i.ToString());
    //here you can specify some properties of created column
    //....
  }
  //add columns
  flyGrid.Columns.Items.AddRange(cols);
}

private void AddRows(FlyGrid flyGrid)
{  
  //clear existing rows
  flyGrid.Rows.Items.Clear();
  //create empty array of nodes for addition to FlyGrid
  Node[] nodes = new Node[3];
  for(int i=0; i < nodes.Length; i++)
  {
     //initialize cell values array
    object[] cellValues = new object[flyGrid.Columns.Items.Count];
    for(int j=0; j < cellValues.Length; j++)
    {
       //initialize cell value with "cell row, col" value
       cellValues[j] = string.Format("cell {0},{1}", i, j);
    }  
    //create new node/row
   nodes[i] = new Node(cellValues)
  }
  //add nodes to flyGrid
  flyGrid.Rows.Items.AddRange(nodes);
}
Link Posted: 14-Mar-2006 06:55
Thanks for the fast reply.