I'm trying to create a custom control that contains a label, a toolstrip and a Datagridview.
When the test form generates the Design code, it saves correctely the toolstrip items but it doesn't save the Datagridview columns. Code DGrid.cs
...
[DesignerAttribute(typeof(MultiDesigner))]
public partial class FDGrid : Panel
{
....
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Category("Bars"), Description("Barra dei comandi.")]
public ToolStrip Barra
{
get { return _barra; }
set { _barra = value; }
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Category("Grid"), Description("Griglia dati.")]
public DataGridView Griglia
{
get { return _griglia; }
set { _griglia = value; }
}
....
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name =
"FullTrust")]
public class MultiDesigner : System.Windows.Forms.Design.ControlDesigner
{
public override void Initialize(IComponent c)
{
base.Initialize(c);
FDGrid ctl = (FDGrid)c;
EnableDesignMode(ctl.Griglia, "Griglia");
EnableDesignMode(ctl.Barra, "Barra");
}
}
...
Code FDGrid.Designer.cs
FDGrid.Designer.cs ....
private FDLabeledImage _titolo;
private ToolStrip _barra;
private DataGridView _griglia;
private void InitializeComponent()
{
this._barra = new System.Windows.Forms.ToolStrip();
this._griglia = new System.Windows.Forms.DataGridView();
this._titolo = new FDControl.FDLabeledImage();
((System.ComponentModel.ISupportInitialize)(this._griglia)).BeginInit();
this.SuspendLayout();
....
((System.ComponentModel.ISupportInitialize)(this._griglia)).EndInit();
this.ResumeLayout(false);
}
....
Code Form1.Designer.cs
....
private void InitializeComponent()
{
this.fdGrid1 = new FDControl.FDGrid(); // OK
this.fdGrid1.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); **// Error**
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); //OK
}
...
private FDControl.FDGrid fdGrid1; //OK
private System.Windows.Forms.ToolStripLabel toolStripLabel1; //OK
private System.Windows.Forms.DataGridViewTextBoxColumnfdGrid1.Column1;//Error
...
help, I would like to understand where am I wrong?