473,396 Members | 1,968 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,396 software developers and data experts.

UserControl with a Decimal Property with a DefaultValue is not handled correctly by Property Editor

Language: VB.Net 2.0 (Windows Application)
IDE: MS VB 2005 Exp. Ed.
Summary: Setting a DefaultValue of type Decimal for the Property of a
UserControl does not work properly - the value appears Bold in the
Property Editor and attempting to Reset the Property fails with an
error (see below.)

Steps to recreate this issue...

Create a UserControl with the following code:
-----
Imports System.ComponentModel

Public Class TestControl

Private _Test As Decimal = 0D
<DefaultValue(0D)> _
Public Property Test() As Decimal
Get
Return _Test
End Get
Set(ByVal value As Decimal)
_Test = value
End Set
End Property

End Class
-----
Add TestControl to a Windows Form. The "Test" property will become
available in the Properties Editor and is initially set to zero.

I do not understand why the zero appears bold, indicating a non-default
value, since the DefaultValue is specified (as Decimal zero).

If the Test property label is right-clicked and Reset is clicked, the
following error appears:

Object of type 'System.Single' cannot be converted to type
'System.Decimal'

Considering that the DefaultValue is specified as 0D (Decimal zero),
this error should not occur. If I change the DefaultValue to 0
(Integer zero), the error changes to "Object of type 'System.Int32'
...."

Am I doing something incorrectly (or misunderstanding anything) or is
this a bug, and, if I need a Decimal Property with a DefaultValue, how
do I get around this?

Apr 12 '06 #1
0 1387

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

Similar topics

2
by: bill yeager | last post by:
When trying to run my web project, I get the following error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Lance | last post by:
I want to be able to reset a complex property in a PropertyGrid. I know that for properties that are ValueTypes you can include System.ComponentModel.DefaultValue in the declaration of the property....
27
by: Just Me | last post by:
I made a Usercontrol that must have AutoScroll set to true when it is used. So I set it to True in the Load event. However the property still shows in the properties window when the control is...
2
by: Murray | last post by:
Sorry if this is not the correct group i could not see one for web controls Hello I am trying to write a cutom web control, The control contains a customer collection that i want to use the...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
1
by: margelos | last post by:
I have created the following usercontrol public class RegisterUser : TemplatedWebControl { private VisFields _vfields = new VisFields(); public VisFields VisibleFields { get { return...
3
by: Johnny Jörgensen | last post by:
Does anybody know how to correctly specify the defaultvalue attribute for a property whose type is an enum. Example: Public Enum TestValues Value1=1 Value2=2 End Enum
4
by: Hamed | last post by:
Hello I have a UserControl sized to 100; 200 When I drop it in my form the initial size is 100;200 (as I prefer). Then I decided to change the size of my UserControl to 200;200 but although I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.