Design-time code generation; InitializeComponent
-
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. -
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.I've solved this. I tried defining several attributes for the property and built the project but nothing seemed to change. After reading this article on [MSDN], section 'Generation of Nested Objects'; "mark a property with DesignerSerializationVisiblity.Content to indicate the code generator should "walk in" to this property and generate code for it" I had set this a while ago but found out I had to re-start visual studio for the changes to take effect?? not sure why I need to restart VS tho, but once I did it worked. Does anyone know why I have to re-start VS to see changes in the UserControl? I'd have thought a simple 'rebuild' would have refreshed the loaded dll.
-
I've solved this. I tried defining several attributes for the property and built the project but nothing seemed to change. After reading this article on [MSDN], section 'Generation of Nested Objects'; "mark a property with DesignerSerializationVisiblity.Content to indicate the code generator should "walk in" to this property and generate code for it" I had set this a while ago but found out I had to re-start visual studio for the changes to take effect?? not sure why I need to restart VS tho, but once I did it worked. Does anyone know why I have to re-start VS to see changes in the UserControl? I'd have thought a simple 'rebuild' would have refreshed the loaded dll.
Hi i'm using this Private _databasefields As New List(Of VerticeBindingField) <DesignerSerializationVisibility(DesignerSerializationVisibility.Content), MergableProperty(True)> _ Public ReadOnly Property DatabaseFields() As List(Of VerticeBindingField) Get Return Me._databasefields End Get End Property
Speto!