Questions tagged [maskedtextbox]

A useful .NET control that allows a user to display and edit values based on the mask defined.

The MaskedTextBox class is a .NET/Windows Forms enhanced TextBox control that supports a declarative syntax for accepting or rejecting user input.

For example, in order to get a phone number in the format (505) 55 555 555, MaskedTextBox is preferred.

Using the Mask property, you can specify the following input without writing any custom validation logic in your application:

  • Required input characters.

  • Optional input characters.

  • The type of input expected at a given position in the mask; for example, a digit, or an alphabetic or alphanumeric character.

  • Mask literals, or characters that should appear directly in the MaskedTextBox; for example, the hyphens (-) in a phone number, or the currency symbol in a price.

  • Special processing for input characters; for example, to convert alphabetic characters to uppercase.

For more information, see MaskedTextBox Class (MSDN).

261 questions
3
votes
3 answers

Windows Forms: Unable to Click to Focus a MaskedTextBox in a Non TopLevel Form

Like the title says, I've got a Child form being shown with it's TopLevel property set to False and I am unable to click a MaskedTextBox control that it contains (in order to bring focus to it). I can bring focus to it by using TAB on the keyboard…
Overhed
  • 1,289
  • 1
  • 13
  • 41
3
votes
3 answers

Email mask for MaskedTextBox in C#

Does anyone have a ready email mask for MaskedTextBox? e.g. aaaa...aaa@fff.ee / aaaa...aaa@ff.ee / aaaa...aaa@fff.eee / aaaa...aaa@ff.eee / p.s. Please do not suggest RegEx!
Mike
  • 563
  • 5
  • 15
  • 32
3
votes
3 answers

Parsing Text from a Masked Text Box

I have a WinForms application written in C# I have until recently many textboxes on my forms where the user inputs financial amounts. I have not incorporated any form of mask initially and whenever I need to work with the values input by the users…
PJW
  • 5,197
  • 19
  • 60
  • 74
3
votes
2 answers

MaskedTextBox If empty insert NULL into SQL

I have got this code below which care whether maskedtextbox is empty. If it is empty it INSERT INTO SQL table __.__.____ - only the mask so I believe it INSERTS NULL But something got wrong when I fill the maskedtextbox. It still INSERT __.__.____…
Marek
  • 3,555
  • 17
  • 74
  • 123
3
votes
7 answers

Limit of characters in string

I have the textbox that takes some string. This string could be very long. I want to limit displayed text (for example to 10 characters) and attach 3 dots like: if text box takes value "To be, or not to be, that is the question:" it display only…
Yo-ho-ho
  • 117
  • 2
  • 10
3
votes
2 answers

Masked TextBox with decimal numbers

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…
Sagar Upadhyay
  • 819
  • 2
  • 11
  • 31
3
votes
1 answer

Masked Textbox for Double?

I have a Masked Textbox and I want it to be able to accept a double value. There shouldn't be a limit of sorts to the amount of characters which can fit before/after the decimal point. I realise there are other ways of doing this such as overriding…
Aabela
  • 1,408
  • 5
  • 19
  • 28
3
votes
4 answers

C# masked text box

How can I change masked text box properties for IP address input? For example private void Interneta_savienojums_Load(object sender, EventArgs e) { maskedTextBox1.Text = " . . . "; maskedTextBox1.PromptChar = ' '; …
deleted
  • 363
  • 4
  • 6
  • 12
3
votes
1 answer

Custom Date format in Masked Text Box

Iam using Masked Text box for inputing a Date. But I want to set custom date format for this text box. How can I set custom date format and validate date on masked text box control
Nithesh Narayanan
  • 11,481
  • 34
  • 98
  • 138
2
votes
2 answers

ASP.NET AJAX Controls in MVC3?

How would I use the ASP.NET AJAX Controls in MVC3? e.g. Masked Edit Box I've installed AJAX Control via NUGET. and tried adding Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" to the top of the page. but it is…
IAmGroot
  • 13,760
  • 18
  • 84
  • 154
2
votes
2 answers

C# How can i get a maskedtextbox column of a bound datagridview to not include the literals?

I have a datagridview which is bound to some data. One of the fields is a phone number and the phone number is stored in the database as an int (ex. 5555555555). I am using a masked textbox in another form just by itself with a phone number and…
bigphildogg86
  • 176
  • 1
  • 7
  • 17
2
votes
1 answer

Masking Password in VBA Excel Input Box

Could someone please help me to mask the password entered to the input box generated using the below code. I will be using Office 365 ProPlus. Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim sPassCheck As String Dim…
Jo365
  • 69
  • 1
  • 1
  • 7
2
votes
0 answers

Masked Text Box - make comma optional

Please see the screenshot below for a MaskedTextBox: and the code below: public Form1() { InitializeComponent(); this.Load += Form1_Load; } private void Form1_Load(object sender, EventArgs e) …
w0051977
  • 15,099
  • 32
  • 152
  • 329
2
votes
1 answer

Move cursor to beginning of MaskedTextBox on focus

When a user is tabbing through a form and focus gets set on a Kendo-Ui for Angular2 MaskedTextBox, the input cursor is at the end of the mask. This is very inconvenient for a user when doing data entry. I have tried to use the onfocus event to…
adova
  • 950
  • 1
  • 8
  • 14
2
votes
2 answers

Having a MaskedTextBox only accept letters

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…
delete
1 2
3
17 18