Patrick B.
2009-06-02 01:42:59 UTC
I have a UserControl that contains a DataGridView.
The UserControl exposes the Columns property of the
DataGridView so users can add columns.
However, at design time the "Add Column" dialog
does not appear in the designer when it should.
Here is a simplified version of my code:
public partial class SpringGrid : UserControl
{
public SpringGrid()
{
InitializeComponent();
}
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView.Columns; }
}
}
I found a thread in a dotnet newsgroup where somebody
was having a similar problem. Linda Liu presented a solution.
The thread is here:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic57961.aspx
Linda's code was very helpful, but I cannot get the solution to work fully.
After implementing Linda's solution, my code now looks something
like this:
[DesignerSerializer(typeof(MyCodeDomSerializer),
typeof(CodeDomSerializer))]
public partial class SpringGrid : UserControl
{
public SpringGrid()
{
InitializeComponent();
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView.Columns; }
}
}
When editing the Columns property of my SpringGrid in the designer,
the DataGridViewColumn Collection Editor appears, but when the
Add button is clicked the Add Column dialog does NOT appear.
Instead, a DataGridViewColumn is automatically added to the collection.
(This is not one of the normal types like a DataGridViewTextBoxColumn.)
I later get the following error message:
At least one of the DataGridView control's columns has no cell template.
Can anyone help?
Thanks!
Patrick
The UserControl exposes the Columns property of the
DataGridView so users can add columns.
However, at design time the "Add Column" dialog
does not appear in the designer when it should.
Here is a simplified version of my code:
public partial class SpringGrid : UserControl
{
public SpringGrid()
{
InitializeComponent();
}
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView.Columns; }
}
}
I found a thread in a dotnet newsgroup where somebody
was having a similar problem. Linda Liu presented a solution.
The thread is here:
http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic57961.aspx
Linda's code was very helpful, but I cannot get the solution to work fully.
After implementing Linda's solution, my code now looks something
like this:
[DesignerSerializer(typeof(MyCodeDomSerializer),
typeof(CodeDomSerializer))]
public partial class SpringGrid : UserControl
{
public SpringGrid()
{
InitializeComponent();
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DataGridViewColumnCollection Columns
{
get { return this.dataGridView.Columns; }
}
}
When editing the Columns property of my SpringGrid in the designer,
the DataGridViewColumn Collection Editor appears, but when the
Add button is clicked the Add Column dialog does NOT appear.
Instead, a DataGridViewColumn is automatically added to the collection.
(This is not one of the normal types like a DataGridViewTextBoxColumn.)
I later get the following error message:
At least one of the DataGridView control's columns has no cell template.
Can anyone help?
Thanks!
Patrick