Re: Focus Stuck on TextBox

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Jul 16, 6:58 pm, "jehugalea...@xxxxxxxxx" <jehugalea...@xxxxxxxxx>
wrote:
Hello:

When we have a text box that is bound to an int?, the text box will
not allow the user to leave the control until it has a valid integer
in it. This is actually very bad. If the user wants to remove the
value, they can't anymore. They can't even leave the form! They are
being forced to enter 0 or some other bogus value.

The weird thing is that it doesn't take affect until they set a value
and lose focus on the control.

Is there some way of shutting this off? I'm assuming it is some sort
of funky validation.

If you want to map empty string input by the user to null value in the
int?, just set the DataSourceNullValue property of the Binding to
"null", and NullValue property of the binding to empty string. You
can't do it from the form designer, so you'll have to write some code:

textBox1.DataBindings["Text"].DataSourceNullValue = null;
textBox1.DataBindings["Text"].NullValue = "";

.



Relevant Pages

  • ASP.NET two way databinding with nulls
    ... than to extend a control etc. ... Problem is, I'm binding the ... DropDownList's SelectedValue to a property of type int?, ... DOTNET 2005's support for two-way databinding and generics seems to be ...
    (microsoft.public.dotnet.general)
  • Re: How can I use C# GUI component in my MFC application.
    ... Here's some stuff I had written on this topic for my book (Extending MFC ... Using a .NET control in an MFC dialog ... we have seen how Windows Forms makes GUI development slightly easier ... BOOL Create(CWnd* pWnd, int x, int y, int cx, int cy); ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Repost for MS: UnsafeNativeMethods.CallWindowProc NullReferenc
    ... The error message that led me to my solution was "Cannot call Dispose while ... Using the .NET Reflector to look at the Control ... NativeWindow has a pointer to a previous window and a pointer to a next ... hWnd, int msg, int wparam, int lparam) + 0x30 bytes ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Possible to pass strings back to ASP from ActriveX?
    ... afx_msg int AboutBox; ... helpstring("AxTemplateTest1 ActiveX Control module"), ... // Primary dispatch interface for CAxTemplateTest1Ctrl ... helpstring("Dispatch interface for AxTemplateTest1 Control")] ...
    (microsoft.public.windowsce.embedded)
  • Re: Possible to pass strings back to ASP from ActriveX?
    ... afx_msg int AboutBox; ... helpstring("AxTemplateTest1 ActiveX Control module"), ... // Primary dispatch interface for CAxTemplateTest1Ctrl ... helpstring("Dispatch interface for AxTemplateTest1 Control")] ...
    (microsoft.public.windowsce.embedded)