473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

EnumConverter interfering with Designer-Generated Code

Here is the background information:

*** *** *** *** *** *** *** ***
In order to display enum string values in my application with
localized values, I created a class called MyEnumConverter that
derives from EnumConverter and will convert To and From localized
string representations of an enum's values.

Now, every enum whose values I desire to be displayed as localized
strings have an attribute
[System.ComponentModel.TypeConverter(typeof(MyEnumC onverter))] added
to them where I tell .NET to use my type converter whenever it tries
to convert these enums to/from strings.

Next, I have a custom ExtenderProvider that extends one of these
"localizable" enums (see enum Unit below) as a property to any .Net
Control. This way, the controls will gain a new "Unit" property. My
ExtenderProvider is a component, so extension is made in the Designer
- not at run-time.

enum Unit
{
ShortDistance,
LongDistance
}

*** *** *** *** *** *** *** ***
Here is my problem:

My EnumConverter is interfering with the Designer-Generated code for
the extended Unit enum property. The English-US localized string
values for the two Unit enum values would be "Short Distance" and
"Long Distance" respectively (with spaces). When I extend the Unit
enum using my ExtenderProvider to a TextBox on my form called
"textBox1", it is supposed to receive a default value of
"ShortDistance" but the Designer-Generated code looks like this:

this.sperryUnitsExtender1.SetUnitGroup(this.textBo x1, UnitGroup.Short
Distance);

This will not compile because the enum name has been given the
localized string rather than the actual enum value name. I've narrowed
the problem to my EnumConverter, because if it's code is commented
out, the Designer-Generated code looks correct, like this:

this.sperryUnitsExtender1.SetUnitGroup(this.textBo x1,
UnitGroup.ShortDistance);

In MyEnumConverter, I use localized string values if the ConvertTo and
ConvertFrom is dealing with the Type of string (assuming it's for
display purposes). Well apparently, .NET is asking for "strings" when
it is creating the Designer-generated code from the control's property
grid, rather than asking for the actual Unit enum Type.

************************************************** ****
QUESTION:
How can I tell if the MyEnumConverter code is being exercised at
Design-Time or at Run-Time (so that I can use the localization
features at Run-Time and the default .NET TypeConverter at
Design-Time)? Is this even the correct way to fix this? Or, should
MyEnumConverter be smarter about it's conversion to localized strings?
Any help is much appreciated...
MattO
Nov 16 '05 #1
0 2451

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Micha³ Trawinski | last post by:
Hi All I'm a student and I've started my experience with Oracle. I must train Oracle Designer, beacuse of this I've instaled Oracle9iDS but if I want to start Oracle designer, it ask's me about...
3
by: kakaz | last post by:
Hi All there! I am quite new in MS SQL administration so let me explain how it work on Your instances of SQL Servers. We have several DTS packages on our server, all of them managed on some...
0
by: Tom Gao | last post by:
Hello, We are having a recurring problem of a typed dataset that we have in a form dissapearing from the VS designer and all bindings being lost. The dataset is defined in another component and...
3
by: thechaosengine | last post by:
Hi all, I wanted to put some common security functions into a class that inherits from the Page class and then use the new class as the basis for all my pages. Unfortunately, if I try and...
1
by: °Ë´óɽÈË | last post by:
I'm studying the designer in .net frame, and met many new things such as System.Windows.Forms.DesignerFrame, System.Windows.Forms.FormDocumentDesigner, but I can't find anything about it in MSDN....
1
by: Sebastian Sylvan | last post by:
Hey. I have two questions. First of all I'm using the Visual C# Express Beta. When you create a windows application it will automatically split the main form into two files using partial...
0
by: Tom Gao | last post by:
Hello, We are having a recurring problem of a typed dataset that we have in a form dissapearing from the VS designer and all bindings being lost. The dataset is defined in another component and...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
6
by: Cirene | last post by:
Does VS 2008 have a good XML designer to work with XML data, schemas, etc...? Any tools to easily add, edit and delete data from an XML file? This is new to me.... Thanks!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.