I have extended DataGridView
. I want to add the new control to the toolbox without adding a reference to a different assembly (using the right-click option "Choose Items"). The control is in the same project of the form, and I do not want to separate them. How can I achieve this?
Thanks.
Edit: This could not possibly a duplicate of a question about user controls if it's not a user control.
Edit 2: The code itself (it's a work in process. It's not finished):
class BindedDataGrid<T> : DataGridView
{
public BindedDataGrid()
{
InitializeComponent();
IEnumerable<PropertyInfo> properties = typeof(T).GetProperties().Where(p => Attribute.IsDefined(p, typeof(BindingValueAttribute)));
foreach (PropertyInfo property in properties)
{
var column = new DataGridViewColumn()
{
HeaderText = ((property.GetCustomAttributes(true)[0]) as BindingValueAttribute).Value
};
Columns.Add(column);
}
}
}