I have a DataGridView with Different Control Type in Each row now i want to create control in each row according to that Control Type Is it Possible? if Yes then How ?
You can add control on the OnRowDatabound of your grid, then you can a controls to your row
To add a control to a cell use
void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row as GridViewRow;
if (row != null)
{
MyObject myObject = new MyObject();
row.Cells[0].Controls.Add(myObject);
}
}
To add a control to the entire row use
void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row as GridViewRow;
if (row != null)
{
MyObject myObject = new MyObject();
row.Controls.Add(myObject);
}
}
Have a look here for the windows forms Grid
You can create your own column class by inheriting the DataGridViewColumn class or any of its derived classes to provide custom appearance, behavior, or hosted controls. For more information, see How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance
http://msdn.microsoft.com/en-us/library/bxt3k60s%28v=vs.80%29.aspx
How to: Customize Cells and Columns in the Windows Forms DataGridView Control by Extending Their Behavior and Appearance
http://msdn.microsoft.com/en-us/library/7fb61s43%28v=vs.80%29.aspx