Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Design-time code generation; InitializeComponent

Design-time code generation; InitializeComponent

Scheduled Pinned Locked Moved C#
visual-studiodesignai-codinghelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    phanton
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • P phanton

      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.

      P Offline
      P Offline
      phanton
      wrote on last edited by
      #2

      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.

      S 1 Reply Last reply
      0
      • P phanton

        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.

        S Offline
        S Offline
        Speto
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups