Results 1 to 7 of 7

Thread: [RESOLVED] Making a usercontrol property editable at design time?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Resolved [RESOLVED] Making a usercontrol property editable at design time?

    Hi...
    i have a property in my user control that is a collection of objects. How can i make it so the users can edit the collection at design time (just like how you can edit the Items property for a listbox in VS.NET and add/remove items)
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: Making a usercontrol property editable at design time?

    vb.net Code:
    1. Imports System.ComponentModel
    2.  
    3. Public Class UserControl1
    4.  
    5.     Private _b As New List(Of Beer)
    6.  
    7.     <DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
    8.     Description("A list of beers is better than just one."), _
    9.     Browsable(True)> _
    10.     Public Property Beers() As List(Of Beer)
    11.         Get
    12.             Return _b
    13.         End Get
    14.         Set(ByVal value As List(Of Beer))
    15.             _b = value
    16.         End Set
    17.     End Property
    18.  
    19. End Class
    20.  
    21. Public Class Beer
    22.  
    23.     Public Enum Tastiness
    24.         Keystone
    25.         Coors
    26.         Guiness
    27.     End Enum
    28.  
    29.     Private _name As String = Nothing
    30.     Private _tastiness As Tastiness = Nothing
    31.  
    32.     Public Property TastinessLevel() As Tastiness
    33.         Get
    34.             Return _tastiness
    35.         End Get
    36.         Set(ByVal value As Tastiness)
    37.             _tastiness = value
    38.         End Set
    39.     End Property
    40.  
    41.     Public Property Name() As String
    42.         Get
    43.             Return _name
    44.         End Get
    45.         Set(ByVal value As String)
    46.             _name = value
    47.         End Set
    48.     End Property
    49.  
    50. End Class

    This works for me. I found this doc helpful in this instance: http://msdn.microsoft.com/en-us/libr...attribute.aspx

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: Making a usercontrol property editable at design time?

    cool works! thanks!!!
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: [RESOLVED] Making a usercontrol property editable at design time?

    hmm but i guess a question that remains is how to you figure out if the property was updated? (it if an item was added to the List ?)
    (I need to update the UI items based on what's in that List collection)
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [RESOLVED] Making a usercontrol property editable at design time?

    Quote Originally Posted by MrPolite
    hmm but i guess a question that remains is how to you figure out if the property was updated? (it if an item was added to the List ?)
    (I need to update the UI items based on what's in that List collection)
    I'm unsure on this. I'll need to research further. In the meantime, this looks like an interesting set of articles: http://amrelsehemy.net/post/2008/01/...ttributes.aspx
    Last edited by nmadd; Aug 20th, 2008 at 08:31 PM.

  6. #6

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: [RESOLVED] Making a usercontrol property editable at design time?

    hmm thanks again
    i can't think of any easy way to do this
    do i need to make my own custom List<> class that would raise an event when someone adds/remove items?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width