maskedtextbox

C# maskedTextbox, how to disable whitespaces?

拜拜、爱过 提交于 2019-12-11 05:21:30
问题 I cant figure out how to disable whitespaces, I tried multiple things, and yes my mask is 00000000000 but still it allows whitespaces. Anyone know a fix? Not much code to show, only: Should only allow numbers to be entered, not whitespaces too :/ 回答1: Add the KeyDown Event to your textbox and then add the following Code in the created method: private void textBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space) { e.Handled = true; e.SuppressKeyPress = true; return; } } 来源

Having a MaskedTextBox only accept letters

六眼飞鱼酱① 提交于 2019-12-11 03:22:52
问题 Here's my code: private void Form1_Load(object sender, EventArgs e) { maskedTextBox1.Mask = "*[L]"; maskedTextBox1.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox1_MaskInputRejected); } How can I set it to accept only letters, but however many the user wants? Thanks! 回答1: This would be easy if masked text boxes accepted regular expression, but unfortunately they don't. One (albeit not very pretty) way you could do it is to use the optional letter ? mask and put in the

VB.Net Custom Mask for Date/Time AM/PM

泄露秘密 提交于 2019-12-11 00:18:57
问题 Here's what I'm trying to do.... I have a field in my application where I am to capture datetime something like this 11/02/2016 12:19 PM (example). I have a field in SQL Server with datatype = smallDatetime . It gets saved like this 2016-11-02 12:19:00 . In my app I set the CUSTOM mask to 00/00/0000 90:00 am. Now what I'm trying to do is populate this saved date into my masked textbox but it does not look proper. Is there a way for me to format is somehow so when I try to populate the field

Masked Input Plugin and regular expressions (for decimal numbers)

荒凉一梦 提交于 2019-12-08 06:28:15
问题 I have a text input field in which I want to insert just numbers, then a comma, and then just two decimal digits. I'm trying to obtain this via jQuery, using Masked Input Plugin, but it seems not to work. This is what I have: <input type="text" name="cash" id="number"/> and <script type="text/javascript"> $.mask.definitions['p']='[0-9]+'; $.mask.definitions['d']='[0-9]{2}'; $("#number").mask("p,d"); <script> But the result is a mask with just one digit, then a comma, and then something I'm

Masked TextBox with decimal numbers

若如初见. 提交于 2019-12-04 12:11:59
In my window application I need masked textbox which accept real decmal numbers. eg. 1) 1.56 2) 22.34 3) 123.34 4) 12312.34 This all value should be valid. Can anyone tell me how can I do this? And ya if anyone have better solution for real decimal numbers, instead of this masked TextBox than I love to see it. Thanks... Use a custom control like this one (modify it to fulfill your needs): using System; using System.ComponentModel; using System.Text; using System.Windows.Forms; using System.Drawing; namespace CustomControls { public enum PasteRejectReasons { Unknown = 0, NoData,

How to get the jQuery MaskedInput unmask() function to work properly?

有些话、适合烂在心里 提交于 2019-12-04 10:32:45
问题 I am trying to have one input on my page that I would like to have a U.S. phone number mask by default. If a end user clicks a checkbox specifing they would like to enter a International phone number I want the mask to be removed. I have tried multiple ways and have been unsuccessful thus far. In the current project I am using jQuery to hide/show a completely different input. But I don't like that option and would like a more streamlined approach. I am using the following: jQuery 1.4.1 (going

How to set Regex Expression as the Mask for a MaskedTextBox in C#?

坚强是说给别人听的谎言 提交于 2019-12-04 04:07:56
问题 I want to set the Mask of MaskedtextBox from Regex expression. Such as i want a valid email, Decimal values and other regex expressions against a MaskedtextBox. 回答1: For reference, this describes what you can do with a mask: http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask(VS.90).aspx The only time I could see you needing to set the mask from a regular expression is if you don't have control over the regular expression, for example if it's acquired from the user

Bind nullable DateTime to MaskedTextBox

Deadly 提交于 2019-12-04 03:22:54
问题 I have a masked text box bound to a nullabe datetime, but when the date is blanked out, the validation on the masked text box won't complete. Is there a way to force this behaviour? I want a blanked out text box to equal a null DateTime. When the textbox is already null, the validation works. It only breaks when there is a date already bound and I try to blank it out. 回答1: I figured out it didn't have to do with the validation. It was when the date was being parsed back to the datetime. This

How to use built-in editors for a exposed properties in User Controls - Mask Property Editor Issue

血红的双手。 提交于 2019-12-04 01:34:25
问题 I think there is a simple solution for my stupid question but I just can't solve it today. I have a User Control that has a MaskedTextBox Control in itself. I have also exposed a few of its properties for the user to modify. One of these properties is Mask property which I want to expose with the ability of starting an editor with predefined values like in a normal MaskedTextBox control. So I created a public property InputMask and set up everything so that it can work but after showing the

How to get the jQuery MaskedInput unmask() function to work properly?

梦想与她 提交于 2019-12-03 06:19:52
I am trying to have one input on my page that I would like to have a U.S. phone number mask by default. If a end user clicks a checkbox specifing they would like to enter a International phone number I want the mask to be removed. I have tried multiple ways and have been unsuccessful thus far. In the current project I am using jQuery to hide/show a completely different input. But I don't like that option and would like a more streamlined approach. I am using the following: jQuery 1.4.1 (going to upgrade to 1.4.2 soon) and jQuery.MaskedInput-1.2.2 <script type="text/javascript"> $(document)