Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / May 2004

Tip: Looking for answers? Try searching our database.

Setting up TypeConverter attribute dynamically.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oleg Slyusarchuk - 05 May 2004 15:37 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.