c# : How ot create a grid row array programatically
Posted
by
user234839
on Stack Overflow
See other posts from Stack Overflow
or by user234839
Published on 2014-06-13T15:21:35Z
Indexed on
2014/06/13
15:24 UTC
Read the original article
Hit count: 307
I am working in c# and i am under a situation where i have a grid (childGrid) and inside this grid i want to create 3 more grids dynamically.
I want to achieve it using arrays. My try to do this is:
Grid[] row = new Grid[counts];
for (int i = 0; i < counts; i++)
{
row[i].RowDefinitions[counts].Add(new RowDefinition());
}
for (int i = 0; i < counts; i++)
{
Grid.SetColumn(txtblkLabel, 0);
Grid.SetRow(row[i], 0);
row[i].Children.Add(txtblkLabel);
Grid.SetColumn(sp, 1);
Grid.SetRow(row[i], 0);
row[i].Children.Add(sp);
Grid.SetColumn(txtblkShowStatus, 2);
Grid.SetRow(row[i], 0);
row[i].Children.Add(txtblkShowStatus);
childGrid.Children.Add(row[i]);
}
the line row[i].RowDefinitions[counts].Add(new RowDefinition());
gives error.
Error 1'System.Windows.Controls.RowDefinition' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Windows.Controls.RowDefinition' could be found (are you missing a using directive or an assembly reference?)
How to achieve this ?
© Stack Overflow or respective owner