it-partners Home   |  Site Map
 Support
       Bits and Pieces

Load itGrid using a .Net array and ValueMatrix

This code shows how to populate itGrid with a .Net array using the Valuematrix property, which expects a Variant.

private void buttonTest_Click(object sender, System.EventArgs e)
{

  object[,] var=new object[10,10];
  object[] var1 = new object [1];

  itGrid1.FixedCols=1;
  itGrid1.FixedRows = 1;
  itGrid1.Cols=11;
  itGrid1.Rows = 11;

  for (int col=0;col<10;col++)
  {
    for (int row=0;row<10;row++)
    {
      var[col,row] = col.ToString() + ", " + row.ToString();
    }
  }

  var1[0] = var;
  itGrid1.set_ValueMatrix(1, 1, 10, 10, ref var1[0]);

}

The key to passing a .Net array to ValueMatrix is the use of var1[0] .

If you use:

itGrid1.set_ValueMatrix(1, 1, 10, 10, ref var);

you will get:

Compiler Error CS1502: The best overloaded method match for 'AxitGrid6.AxitGrid.set_ValueMatrix(int, int, int, int, ref object)' has some invalid arguments, and
Compiler Error CS1503: Argument '5': cannot convert from 'ref object[*,*]' to 'ref object'.