for (int i = 0; i < 10; i++)
{
GridViewColumn grid_Column = new GridViewColumn();
grid_Column.Header = "num : " + i;
grid_Column.Width = 20;
grid_Column.Name = "column" + i.ToString();
view.Columns.Add(grid_Column);
}
GridViewRow[] item_v = new GridViewRow[size[1]];
for (int i = 0; i < 10; i++)
{
item_v[i] = new GridViewRow();
for (int j = 0; j < 10; j++)
{
GridViewCell cell = new GridViewCell();
cell.Content = ((i + 1) * (j + 1)).ToString();
item_v[i].Cells.Add(cell);
}
view.Items.AddNewItem(item_v);
}
0
Vladimir Stoyanov
Telerik team
answered on 11 Dec 2019, 12:28 PM
Hello,
Thank you for the shared code snippet.
Please, allow me to start by saying that the RadGridView is designed to be a databound control and as such there isn't a way to populate individual cells in code. The rows in the RadGridView display one object from its ItemsSource and each cell shows the value of one property of that object. With this in mind, you can create a collection of some object and bind it to the ItemsSource of the RadGridView as demonstrated in the Getting Started article.
On a side note, you can also check out the RadVirtualGrid, which is a more light-weight grid version, but with less features than the RadGridView. That said, it allows for populating its cells in a manner similar to what you are going for.
I hope this helps.
Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.Learn More.