Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / January 2008

Tip: Looking for answers? Try searching our database.

How to get the edited value in a NumericUpDown?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nvx - 23 Jan 2008 10:15 GMT
Hello,
I would like to get the edited value (an equivalent to the
EditedFormatedValue in case of a DataGridViewCell) of the
NumericUpDown control before closing a dialog. The thing is if the
control becomes clear (no input, just a blank field) and user hits the
accept button (or just simply an Enter key), the previous value of
this control is considered. I need it to get the value zero in such a
case. Is there a way to get this done?

Thanks for any help.

Best regards,
nvx
Morten Wennevik [C# MVP] - 24 Jan 2008 06:41 GMT
Hi nvx,

The only way it appears you can catch the user deleting the content is by
inheriting NumericUpDown and override for instance the Text property

   public class MyNumeric : NumericUpDown
   {
       public override string Text
       {
           get
           {
               if (base.Text == "")
                   base.Text = Minimum.ToString();
               
               return base.Text;
           }
           set
           {
               base.Text = value;
           }
       }
   }

Interestingly, the setter will never get notified of the empty string so you
need to catch it in the getter.

Signature

Happy Coding!
Morten Wennevik [C# MVP]

> Hello,
> I would like to get the edited value (an equivalent to the
[quoted text clipped - 9 lines]
> Best regards,
> nvx
nvx - 24 Jan 2008 10:28 GMT
Dear Morten,
thank you for the info. I was afraid it has to be done this
(inconvenient) way, but it is better to be sure than try the easy way
with no result... ;)

Best regards,
nvx

On 24 Led, 07:41, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.com> wrote:
> Hi nvx,
>
[quoted text clipped - 39 lines]
> > Best regards,
> > nvx

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.