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. Exposing class properties for design time use

Exposing class properties for design time use

Scheduled Pinned Locked Moved C#
questiondesign
14 Posts 4 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.
  • U User 4467139

    use browsable attribute. [BrowsableAttribute(true)]

    K Offline
    K Offline
    kanchoette
    wrote on last edited by
    #4

    Nice thought. But, however, this did not work for me.

    M U 2 Replies Last reply
    0
    • K kanchoette

      Nice thought. But, however, this did not work for me.

      M Offline
      M Offline
      moon_stick
      wrote on last edited by
      #5

      Works for me - [System.ComponentModel.Browsable(true)]

      It definitely isn't definatley

      K 1 Reply Last reply
      0
      • M moon_stick

        Works for me - [System.ComponentModel.Browsable(true)]

        It definitely isn't definatley

        K Offline
        K Offline
        kanchoette
        wrote on last edited by
        #6

        That's interesting. Mmm ... so in the code shown below, exactly where are you inserting the [System.ComponentModel.Browsable(true)] please?

        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Diagnostics;
        using System.Linq;
        using System.Text;
        using System.Windows.Forms;

        namespace MultiColumnComboBox
        {

        public partial class MultiColumnComboBox : ComboBox
        {
            
            public class Column
            {
                private bool \_autoWidth = true;
                private int \_columnWidth;
        
               
                public bool AutoWidth
                {
                    get { return \_autoWidth; }
                    set { \_autoWidth = value; }
                }
                
                public int ColumnWidth
                {
                    get { return \_columnWidth; }
                    set { \_columnWidth = value; }
                }
            }
            
            public MultiColumnComboBox()
            {
                InitializeComponent();
            }
        
            public MultiColumnComboBox(IContainer container)
            {
                container.Add(this);
        
                InitializeComponent();
            }
        }
        

        }

        M 1 Reply Last reply
        0
        • K kanchoette

          That's interesting. Mmm ... so in the code shown below, exactly where are you inserting the [System.ComponentModel.Browsable(true)] please?

          using System;
          using System.Collections.Generic;
          using System.ComponentModel;
          using System.Diagnostics;
          using System.Linq;
          using System.Text;
          using System.Windows.Forms;

          namespace MultiColumnComboBox
          {

          public partial class MultiColumnComboBox : ComboBox
          {
              
              public class Column
              {
                  private bool \_autoWidth = true;
                  private int \_columnWidth;
          
                 
                  public bool AutoWidth
                  {
                      get { return \_autoWidth; }
                      set { \_autoWidth = value; }
                  }
                  
                  public int ColumnWidth
                  {
                      get { return \_columnWidth; }
                      set { \_columnWidth = value; }
                  }
              }
              
              public MultiColumnComboBox()
              {
                  InitializeComponent();
              }
          
              public MultiColumnComboBox(IContainer container)
              {
                  container.Add(this);
          
                  InitializeComponent();
              }
          }
          

          }

          M Offline
          M Offline
          moon_stick
          wrote on last edited by
          #7

          As an attribute on the property - in my code: [System.ComponentModel.Browsable(true)] public string DataItemLabelTitle { get { return this.lblDataItem.Text; } set { this.lblDataItemText = value; } }

          It definitely isn't definatley

          K 1 Reply Last reply
          0
          • M moon_stick

            As an attribute on the property - in my code: [System.ComponentModel.Browsable(true)] public string DataItemLabelTitle { get { return this.lblDataItem.Text; } set { this.lblDataItemText = value; } }

            It definitely isn't definatley

            K Offline
            K Offline
            kanchoette
            wrote on last edited by
            #8

            Yes, this works for me in your context. But when the property is contained within my class 'Column' it fails. Any ideas would be much appreciated.

            M 1 Reply Last reply
            0
            • K kanchoette

              Yes, this works for me in your context. But when the property is contained within my class 'Column' it fails. Any ideas would be much appreciated.

              M Offline
              M Offline
              moon_stick
              wrote on last edited by
              #9

              When you place an instance of your combo box onto the designer window, the Property pane shows the browsable properties of that object. Your 'Column' class isn't a property - it isn't even an instance. What exactly are you expecting to see here? By entering a value in the property pane, what behaviour are you expecting?

              It definitely isn't definatley

              K 1 Reply Last reply
              0
              • M moon_stick

                When you place an instance of your combo box onto the designer window, the Property pane shows the browsable properties of that object. Your 'Column' class isn't a property - it isn't even an instance. What exactly are you expecting to see here? By entering a value in the property pane, what behaviour are you expecting?

                It definitely isn't definatley

                K Offline
                K Offline
                kanchoette
                wrote on last edited by
                #10

                I was expecting to see the additional properties 'AutoWidth' and 'ColumnWidth'.

                M 1 Reply Last reply
                0
                • K kanchoette

                  Nice thought. But, however, this did not work for me.

                  U Offline
                  U Offline
                  User 4467139
                  wrote on last edited by
                  #11

                  [Message Deleted]

                  K 1 Reply Last reply
                  0
                  • U User 4467139

                    [Message Deleted]

                    K Offline
                    K Offline
                    kanchoette
                    wrote on last edited by
                    #12

                    I am creating a custom control.

                    1 Reply Last reply
                    0
                    • K kanchoette

                      I was expecting to see the additional properties 'AutoWidth' and 'ColumnWidth'.

                      M Offline
                      M Offline
                      moon_stick
                      wrote on last edited by
                      #13

                      You missed the point I was making - you can only display and change the properties for an instance of a class. What you're asking to do doesn't make any real sense.

                      It definitely isn't definatley

                      K 1 Reply Last reply
                      0
                      • M moon_stick

                        You missed the point I was making - you can only display and change the properties for an instance of a class. What you're asking to do doesn't make any real sense.

                        It definitely isn't definatley

                        K Offline
                        K Offline
                        kanchoette
                        wrote on last edited by
                        #14

                        Your are right (of course). I realise my error now that I have had another jolt of coffee. Thanks for your patience. Mondays ..... :-O

                        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