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. c# hide/remove properties from propertygrid

c# hide/remove properties from propertygrid

Scheduled Pinned Locked Moved C#
csharpcsshelpquestion
6 Posts 3 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.
  • M Offline
    M Offline
    Member 2068169
    wrote on last edited by
    #1

    How can i hide/remove some of the properties from a propertygrid. I have a used a property grid in my project to display the properties of a label and picturebox in runtime, but i do not want all the properties to be displayed. please help Janardhan

    L 1 Reply Last reply
    0
    • M Member 2068169

      How can i hide/remove some of the properties from a propertygrid. I have a used a property grid in my project to display the properties of a label and picturebox in runtime, but i do not want all the properties to be displayed. please help Janardhan

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      add attribute [Browsable(false)] or [Browsable(true)]

      M 1 Reply Last reply
      0
      • L Lost User

        add attribute [Browsable(false)] or [Browsable(true)]

        M Offline
        M Offline
        Member 2068169
        wrote on last edited by
        #3

        Given below is is my implementation, where should i add [Browsable(false)] or [Browsable(true)] PropertyGrid pgGrid = new PropertyGrid(); pgGrid.CommandsVisibleIfAvailable = true; pgGrid.Height = 400; pgGrid.Width = 250; pgGrid.Location = new Point(this.Width - (pgGrid.Width + 10), 0); pgGrid.Dock = DockStyle.Fill; this.Controls.Add(pgGrid); pgGrid.Visible = true; pgGrid.SelectedObject = label1; Regards Janardhan

        L 1 Reply Last reply
        0
        • M Member 2068169

          Given below is is my implementation, where should i add [Browsable(false)] or [Browsable(true)] PropertyGrid pgGrid = new PropertyGrid(); pgGrid.CommandsVisibleIfAvailable = true; pgGrid.Height = 400; pgGrid.Width = 250; pgGrid.Location = new Point(this.Width - (pgGrid.Width + 10), 0); pgGrid.Dock = DockStyle.Fill; this.Controls.Add(pgGrid); pgGrid.Visible = true; pgGrid.SelectedObject = label1; Regards Janardhan

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          in your label1. This is just sample :

          using System;
          using System.ComponentModel;
          using System.Windows.Forms;

          namespace WindowsFormsApplication2
          {
          public partial class Form1 : Form
          {
          public Form1()
          {
          InitializeComponent();
          }

          private void Form1\_Load(object sender, EventArgs e)
          {
            MyClass myClass = new MyClass();
            propertyGrid1.SelectedObject = myClass;
          }
          

          }

          public class MyClass
          {
          private int _thisIsNotVisible;
          private int _thisIsVisible;

          \[Browsable(true)\]
          public int ThisIsVisible
          {
            get { return \_thisIsVisible; }
            set { \_thisIsVisible = value; }
          }
          
          \[Browsable(false)\]
          public int ThisIsNotVisible
          {
            get { return \_thisIsNotVisible; }
            set { \_thisIsNotVisible = value; }
          }
          

          }
          }

          M 1 Reply Last reply
          0
          • L Lost User

            in your label1. This is just sample :

            using System;
            using System.ComponentModel;
            using System.Windows.Forms;

            namespace WindowsFormsApplication2
            {
            public partial class Form1 : Form
            {
            public Form1()
            {
            InitializeComponent();
            }

            private void Form1\_Load(object sender, EventArgs e)
            {
              MyClass myClass = new MyClass();
              propertyGrid1.SelectedObject = myClass;
            }
            

            }

            public class MyClass
            {
            private int _thisIsNotVisible;
            private int _thisIsVisible;

            \[Browsable(true)\]
            public int ThisIsVisible
            {
              get { return \_thisIsVisible; }
              set { \_thisIsVisible = value; }
            }
            
            \[Browsable(false)\]
            public int ThisIsNotVisible
            {
              get { return \_thisIsNotVisible; }
              set { \_thisIsNotVisible = value; }
            }
            

            }
            }

            M Offline
            M Offline
            Member 2068169
            wrote on last edited by
            #5

            Where is label1 used here?

            J 1 Reply Last reply
            0
            • M Member 2068169

              Where is label1 used here?

              J Offline
              J Offline
              Jordon4Kraftd
              wrote on last edited by
              #6

              Given below is is my implementation, where should i add [Browsable(false)] or [Browsable(true)]

              PropertyGrid pgGrid = new PropertyGrid();
              pgGrid.CommandsVisibleIfAvailable = true;
              pgGrid.Height = 400;
              pgGrid.Width = 250;
              pgGrid.Location = new Point(this.Width - (pgGrid.Width + 10), 0);
              pgGrid.Dock = DockStyle.Fill;
              this.Controls.Add(pgGrid);
              pgGrid.Visible = true;
              pgGrid.SelectedObject = label1; <--- here!

              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