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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Attributes displaying lists

Attributes displaying lists

Scheduled Pinned Locked Moved C#
questiondesigntutoriallounge
1 Posts 1 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.
  • M Offline
    M Offline
    MBursill
    wrote on last edited by
    #1

    I have a UserControl that contains the property SelectedItem. I want to expose that property at design time. The property is of type SomeClass (just an example). At design time I want the user to be able to set the SelectedItem property to ONLY one of the instances of SomeClass contained in a List. How can I go about doing this?

    public class MyTestControl : UserControl
    {
    private List myList = new List();
    SomeClass _mySelectedItem;

    public MyTestControl()
    {
        // populating the list with random stuff. Each instance of SomeClass
        // will override ToString which is what I would like to have show up
        // in the property window (see below)
        myList.Add(new SomeClass());
        myList.Add(new SomeClass());
        myList.Add(new SomeClass());
    }
    
    \[Browsable(true)\]
    // what could go here to make this property display all
    // the items of myList as options to choose from in the
    // property window at design time?
    public SomeClass SelectedItem
    {
        get
        {
            return \_mySelectedItem;
        }
    
        set
        {
            \_mySelectedItem = true;
        }
    }
    

    }

    -Mike.

    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