User Control - ListDictionary property

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

I'm trying to create a user control that would have a ListDictionary
property. When trying to use the property and set values for this
collection, the dialog box that appears has everything disabled. I'm
unsure of what I have to have set in code in order to enable this??
 
Doug said:
I'm trying to create a user control that would have a ListDictionary
property. When trying to use the property and set values for this
collection, the dialog box that appears has everything disabled. I'm
unsure of what I have to have set in code in order to enable this??

There is no designer for this class. You would need to write a designer.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
I'm not sure I understand your answer. Basically, I need a way to have
my user control contain a collection property (it doesn't have to be a
list dictionary one). So if I have a property like this:

private ListDictionary m_oValues = new ListDictionary();
[MergableProperty(false)]
[RefreshProperties(RefreshProperties.All)]
public ListCollection Values
{
get
{
return m_oValues;
}
set
{
m_oValues = value;
}
}

In the properties box this property will show up with an ellipsis.
When I click the ellipsis the Object Collection Editor box will display
but everything is disabled.

I've been doing some reading and it seems that you need a seperate
class that inherits from CollectionBase to do this. So I wrote one
just for a test:

public class Test : CollectionBase
{
public void Add(string o)
{
List.Add(o);
}
public void Remove(string o)
{
List.Remove(o);
}
public string this[int index]
{
get
{
return (string)List[index];
}
set
{
List[index] = value;
}
}
}

and then switch the code that read like this:

private ListDictionary m_oValues = new ListDictionary();

to this:

private Test m_oValues = new Test();


That seemed to work, and the ADD button was now enabled in the Object
Collection Editor, however when I tried to use the ADD button, I got
the error "Constructor on System.String not found". So apparently, my
collection cannot be of a string type.

I'm really unsure of what I'm doing here or if I'm going way down the
wrong path. What I need is the ability to have a control with a
collection property that develpers can add and remove info from.
 
One other thing. I figured out how to do this if I went with a
StringCollection instead of a ListDictionary. However that won't work
for me as it brings the string collection editor and only allows one
entry (per line), it doesn't have an option for description and value.
I'm hoping to have a collection that does something like this:

Description = Yes Value = Y
Description = No Value = N
Description = Unknown Value = U
 
Doug said:
I'm not sure I understand your answer. Basically, I need a way to have

Properties, especially classes just dont "magically" have editors in Visual
Studio. Someone has to write them. Microsoft made editors for many of the
common classes, but other classes that it didnt make sense to make a generic
editor for, or just didnt make sense they didnt.

So you have to write a property editor for your class/property, or
ListDictionary if you want it to be that generic.
In the properties box this property will show up with an ellipsis.
When I click the ellipsis the Object Collection Editor box will display
but everything is disabled.

Because its probably invoking some default editor with basic actions.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
Back
Top