469,267 Members | 971 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

User Control - ListDictionary property

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??

Jul 21 '05 #1
4 3502
"Doug" <dn******@dtgnet.com> wrote in news:1115038097.606701.212890
@o13g2000cwo.googlegroups.com:
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/
Jul 21 '05 #2
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.

Jul 21 '05 #3
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

Jul 21 '05 #4
"Doug" <dn******@dtgnet.com> wrote in news:1115043776.235345.221630
@l41g2000cwc.googlegroups.com:
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/
Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jim Douglas | last post: by
6 posts views Thread by Allen Jones | last post: by
6 posts views Thread by martin | last post: by
2 posts views Thread by SK | last post: by
4 posts views Thread by louise raisbeck | last post: by
1 post views Thread by John Keenan | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.