Forum  Commercial Foru...  Commercial Foru...  NumericUpDown which allows nullable value
Previous Previous
 
Next Next
New Post 7/9/2012 5:21 AM
  wit205
53 posts
No Ranking


NumericUpDown which allows nullable value  

Hi, I would like to have a control, exactly like NumericUpDown, but with two diffrences.

1) Value has to be nullable. Now when user clear the field, control would bring previous value instead of showing blank field.

2) Second.. I would like to have, but this is not so much important as first one. I would like to throw away Up Down button.

I had an idea to do sth with custom control inherieted from NumericUpDown, but I can't even access to Control collection. Like that:

protected override void UpdateEditText()
        {
            base.Controls[1].Text = "";
        }

 Could you pleas help me with NumericUpDown which allows nullable value (and then viewing empty field) ?

Thanks for your help, Best regards,

 
New Post 7/9/2012 1:30 PM
  palli
14313 posts
1st Level Poster




Re: NumericUpDown which allows nullable value  

 Hi,

Getting rid of the arrows is just a property setting, setting NumericUpDown.HideButtons = true.

Customizing the control to make it nullable is a bit more effort, which has more than one solution. The decision you need to make first is what datatype you want the value property to be, as decimal types in .NET don't accept null values so that type will not work for you directly. 

I built a Skinable NumericUpDown control as a demo case for you where I make the Value property of type object and then make some changes to the control, both server-side and also how it is rendered. The changes server-side should be obvious when you look at the sample. The changes client-side (the XSLT) may not be as obvious, but the idea is that the control will render an extra flag notifying the client-side if it should be interpreted as null or not. If null, then the xslt will render an empty control (no value) but if false, it will render the value as it usually does. This may not be 100% accurate, but for the most part I think it works. 

The demo can be seen from either the Case studies section in the custom controls article, or directly from the NumericUpDown article.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
Previous Previous
 
Next Next
  Forum  Commercial Foru...  Commercial Foru...  NumericUpDown which allows nullable value
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS