المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Design-time code generation; InitializeComponent



C# Programming
03-18-2010, 05:11 PM
Hi,

I'm writing a UserControl that has similar functionality to the ListView but I'm writing it from scratch, it has columns and rows of type List;

Everything is generally fine with the project its moving along except when I add items to columns or rows at design time, the IDE seems to be doing something odd when generating code in InitializeComponent().

For instance;

private void InitializeComponent()
{
BigView.Column column1 = new BigView.Column();
this.bigViewer1 = new BigView.BigViewer();
column1.Value = "Key";
column1.Width = 253;
new BigView.ColList().Add(column1); }

Every time I re-compile the project the columns are not reloaded in the designer, because the code above never really assosciates the column with my user control. I've tried lots of combination of attributes but nothing solves my problem.

This is what I'd expect the code should look like;

private void InitializeComponent()
{
BigView.Column column1 = new BigView.Column();
this.bigViewer1 = new BigView.BigViewer();
column1.Value = "Key";
column1.Width = 253;
this.bigViewer1.Columns.Add(column1); }
Does anyone know why the designer would do this? Why it creates a column but never adds it to my Columns property?

The columns property is a List. The same thing happens with my rows property which is a List.