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. Hiding unwanted properties [modified]

Hiding unwanted properties [modified]

Scheduled Pinned Locked Moved C#
helptutorialquestionlearning
3 Posts 3 Posters 1 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.
  • C Offline
    C Offline
    Chris_McGrath
    wrote on last edited by
    #1

    I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property... class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} } This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface... interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} } I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007

    A T 2 Replies Last reply
    0
    • C Chris_McGrath

      I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property... class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} } This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface... interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} } I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007

      A Offline
      A Offline
      AlwiNus
      wrote on last edited by
      #2

      You can try to create a custom TypeConverter[^] for your window, which filters the Window properties.

      [Converter(typeof(MyWindowConverter ))]
      class MyWindow : Form
      {
      ...
      }

      or maybe:

      [Converter(typeof(MyWindowConverter ))]
      interface Window : IComponent
      {
      ...
      }

      class MyWindowConverter : TypeConverter {

      override GetPropertiesSupported()
      {
      // indicate you want property filtering
      return true;
      }

      override GetProperties(...)
      {
      // return only the properties you want here
      // not sure how to do this out of my head, sorry
      }

      }

      Sorry i don't have a complete answer, but i hope this gives you a start. If you don't get it working please reply so i can research further. - alwinus

      1 Reply Last reply
      0
      • C Chris_McGrath

        I have a Control and a Form. The Form is a member of the Control. I exposed the form on the Control using a get property... class MyWindow : Form { ....public int MyProp ....{ ........get... set... ....} } class MyControl : Control { ....public MyWindow Window ....{ ........get... set... ....} } This of course shows up in the property Window of the Control and has all the Form properties and my properties. I however don't want to see any of the Form properties, only the Window ones. So I decided to write an interface... interface Window : IComponent { ....int MyProp ....{ ........get; set; ....} } class MyWindow : Form, Window { ... } class MyControl : Control { ....public Window Window ....{ ........get... set... ....} } I found out the interface will not show up in the designer if it doesn't inherit from IComponent. However, even when I do this all of the Form properties are still shown. Does anyone know how to fix this? At the moment I have settled for pass-through properties on my Control. (And I don't want to override evey method add the Browsable(false) attribute to each one Thanks, Chris McGrath -- modified at 21:04 Thursday 12th April, 2007

        T Offline
        T Offline
        Tristan Rhodes
        wrote on last edited by
        #3

        I think these attributes might be what you're looking for: [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] Tris Edit: Just re-read your post. Nevermind.

        ------------------------------- Carrier Bags - 21st Century Tumbleweed.

        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