[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):afrog:
Re: Making a usercontrol property editable at design time?
vb.net Code:
Imports System.ComponentModel
Public Class UserControl1
Private _b As New List(Of Beer)
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
Description("A list of beers is better than just one."), _
Browsable(True)> _
Public Property Beers() As List(Of Beer)
Get
Return _b
End Get
Set(ByVal value As List(Of Beer))
_b = value
End Set
End Property
End Class
Public Class Beer
Public Enum Tastiness
Keystone
Coors
Guiness
End Enum
Private _name As String = Nothing
Private _tastiness As Tastiness = Nothing
Public Property TastinessLevel() As Tastiness
Get
Return _tastiness
End Get
Set(ByVal value As Tastiness)
_tastiness = value
End Set
End Property
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
End Class
This works for me. I found this doc helpful in this instance: http://msdn.microsoft.com/en-us/libr...attribute.aspx
Re: Making a usercontrol property editable at design time?
cool works! thanks!!! :) :) :)
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)
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
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?
Re: [RESOLVED] Making a usercontrol property editable at design time?