Please, help with the following.
I have a property "UserName".
When user names are available, I use TypeEditor: derived from
StringConverter with
public override TypeConverter.StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
implemented, so I'm able to select a UserName from the drop-down provided
with the TypeEditor.
However, when user names are NOT available, the drop-down is empty, and I'm
not able to type in the name manually,
because I'm limited to pre-selected values. The same is true when I'd like
to enter a new Name with values already in the drop-down.
My idea is to set up TypeEditor attribute dynamically, or in the second case
(empty drop-down) just reset the attribute,
to make it possible to enter the UserName by hand.
I don't think it's a good idea to implement CollectionEditor in this case
since I don't need to store this collection, but need only one value.
Thanks,
Oleg
DRaiko - 06 May 2004 08:47 GMT
Hi, Oleg!
Attributes are "constants" computed at compile time. They are
even "more static" than the static members. It is too late to
change them when the program (your control with some attributes
assigned to some properties) is used in another application
(and is already compiled, i suppose).
You have only one chance -- implementing the needed logic *in*
the converter (dynamically, at the time, that is "runtime" for
the converter and "design time" for the designed component
instance).
Look at the GetStandardValuesExclusive(). It must not deliver
the same value each time it is called. You can compute
the return value considering what ever you want (the context
argument gives access at least to the designed control instance,
designer host and many other things that help).
Im not 120% sure, but i hope, GetStandardValuesExclusive()
is called each time the user starts editing the property
and you can decide: to allow or not to allow.
Another question. You say you must allow entering new names
when the list is empty. And what is when there is only one name
in the list? Are you sure, that the user does not want to append
one more? I mean: (i) maybe it must be always allowed to enter
new names or (ii) you need different evidences (not simply
NameList.Count == 0) to decide whether the list is complete
and may not be extended.
HTH,
Dima.
> Please, help with the following.
>
[quoted text clipped - 23 lines]
>
> Oleg
Oleg Slyusarchuk - 06 May 2004 16:14 GMT
Thanks a lot, Dima
It's definitelly a right place.
GetStandardValuesExclusive() returning false let's me to enter a new value
manually
and resolves my problem.
While describing my problem I simplified it a little.
I can adjust logic in GetStandardValuesExclusive() accordingly .
regards,
Oleg
> Hi, Oleg!
>
[quoted text clipped - 57 lines]
> >
> > Oleg