I am using WPF Application. I need to Create Button Dynamically with some properties and i add the buttons in dataGridView Rows. But Datatable is not Contains The Button DataType Then how to do this Please Someone Help me thanks in advance.
This is My Code:
DataTable NewDataTable = new DataTable();
for (int i = 0; i < Row * level; i++)
{
Button[] buttonArray = new Button[position];
string Col1 = "Rows";
string Col2 = "Levels";
for (int j = 0; j < position; j++)
{
if (j == 1)
{
Col1 = "Rows";
}
else if (j == 2)
{
Col2 = "Levels";
}
else
{
buttonArray[j] = new Button();
buttonArray[j].Content = "Postion " + j;
buttonArray[j].ToolTip = "Postion " + j;
}
}
NewDataTable.Rows.Add(Col1, Col2, buttonArray[j]);
}
Code Behind
Dgrid.ItemsSource = NewDataGrid.DefaultView();
ItemsSource. There's rarely a place for DataTable in WPF app anyways. For further info and examples check out MSDN-DataGrid.