Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:06:22+00:00 2026-06-04T17:06:22+00:00

I have written a .Net 4.0 Winforms Numeric Editor control (which inherits from TextBox),

  • 0

I have written a .Net 4.0 Winforms Numeric Editor control (which inherits from TextBox), and I have added a Value property that is a nullable decimal type, as follows:

Public Class NumericEditor
    Inherits TextBox

    Private _value As Decimal? = Nothing

    <DefaultValue(GetType(Decimal?), "Nothing"), Bindable(True)>
    Public Property Value() As Decimal?
        Get
           Return _value
        End Get
        Set(ByVal newvalue As Decimal?)
            _value = newvalue
        End Set
    End Property

End Class

I am binding a DataTable field to an instance of the control as follows:

Dim bindingNew As New Binding("Value", _bindingSource, strFieldName, True, DataSourceUpdateMode.OnValidation, Nothing)
NumericEditor1.DataBindings.Add(bindingNew)

(I’ve created a variable for the binding object to aid in debugging, but the CLR exception is thrown on the second line.)

When databinding a field of type Int32 containing a valid value to the Value property, I’m getting a FormatException raised:

System.FormatException occurred
  Message=Input string was not in a correct format.
  Source=mscorlib
  StackTrace:
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
  InnerException: 

Likewise, when databinding a field of type Int32 that contains a DBNull, I’m getting a general Exception raised:

System.Exception occurred
  Message=Nothing is not a valid value for Decimal.
  Source=System
  StackTrace:
       at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
  InnerException: System.FormatException
       Message=Input string was not in a correct format.
       Source=mscorlib
       StackTrace:
            at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
            at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
            at System.ComponentModel.DecimalConverter.FromString(String value, NumberFormatInfo formatInfo)
            at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
       InnerException: 

At this point, I’m at a loss for how to get around this exception, particularly when I’m databinding a number field to a number property, and there should be no string conversion happening. Any ideas?

(To further complicate things, I’m using a similar technique for another control where I databind a DateTime field to a nullable DateTime property, and that control works just fine.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:06:24+00:00Added an answer on June 4, 2026 at 5:06 pm
    <DefaultValue(GetType(Decimal?), "Nothing")>
    

    The string “Nothing” is the problem here. That’s a VB.NET specific keyword, only the VB.NET compiler knows what that means. The .NET framework binding code uses type converters that don’t know nothing about “Nothing”.

    Just remove it because the default value for a Decimal? already is Nothing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WinForms application written in C# for .NET 3.5 that needs to
I have a .NET application that was written in C# and VB.NET using WinForms.
I have an application written in .net winforms. There is a form that shows
We have an application written in .net, c#, winforms. We noticed that sometimes when
I have this app written in VB.Net with winforms that shows some stats and
I have a WinForms application that was written in C# .NET 3.5. This application
We have a WinForms app, written in VB.NET (CLR 2.0), that does a lot
I have written a .net winforms application that does some heavy processing and slows
I have written a WinForms app that uploads addresses from a spreadsheet, and geocodes
I have written a wrapper application in .Net that starts another WinForms application with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.