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

  • Home
  • SEARCH
  • 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 7053447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:30:23+00:00 2026-05-28T03:30:23+00:00

I have a winforms application with a numeric field on a form. This starts

  • 0

I have a winforms application with a numeric field on a form. This starts out null then if I set it to a number, change focus then clear again the textbox changes back to the number previously entered. If I change the number eg. from 4 to 5 it is updated correctly but I want the user to be able to clear what has been entered.

Here is some sample code that demonstrates this behaviour:

public partial class Form1 : Form
{
    DataTable table = new DataTable("TableName");
    public Form1()
    {
        DataColumn column = new DataColumn("NumericColumnName", typeof(Double));
        column.AllowDBNull = true;
        table.Columns.Add(column);
        object[] rowData = new object[1];
        rowData[0] = DBNull.Value;
        table.Rows.Add(rowData);

        InitializeComponent();

        BindingSource bindingSource = new BindingSource();
        bindingSource.DataSource = table;
        Binding binding = new Binding("Text", bindingSource, "NumericColumnName");
        textBox1.DataBindings.Add(binding);
    }
}

This is in a brand new .net 3.5 forms project in Visual Studio 2008. I added two textboxes to the form.

My actual application generates the dataset differently however it has the same behaviour. Do bindings to numeric columns of a datatable allow nulls.

  • 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-05-28T03:30:24+00:00Added an answer on May 28, 2026 at 3:30 am

    In fact You can allow NULL values, however You have to add additional parsing to the code:

    binding.Parse += new ConvertEventHandler(ParseNumeric);
    

    where ParseNumeric has the following form:

    private void ParseNumeric(object sender, ConvertEventArgs e)
    {
        if(e.Value.Equals(""))
            e.Value = DBNull.Value;
    }
    

    for me this code allows empty texts in text boxes which are then represented by NULL values in database.

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

Sidebar

Related Questions

I have an WinForms application with this Main Form : ICountRepository countRepository; public MainForm(ICountRepository
I have a winforms application that includes an Administration form (call it 'adminForm') and
I have a winforms application that doesn't really have a main form - it's
I have a WinForms application, running on .net 3.5. This Application generates HTML on
I have a WinForms C# application. There is a WebBrowser control on the form
I have a WinForms application that was written in C# .NET 3.5. This application
We have a WinForms application that we are progressively converting to WPF. At this
I have a WinForms application. the main form is has a lot of controls
I have WinForms application. My Form derived class has UserControl derived class. I simply
I have a WinForms application (VS 2008, .NET 3.5) that has a form 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.