简体   繁体   中英

C# - Draw grid lines on multiline textbox

I'm looking to know how I can draw a grid in a multine textbox, where in each square of the grid there will be a letter, something like this:

在此处输入图像描述

But, for a multiline textbox, I want to use some fixed width font, like, CONSOLAS, so, this is will help a lot... I tried to change this code ( How to customize Winforms textbox text characters separated? ) to work on textbox, but, didn't work.

I think that you want to show the operator some fill-in box: A box where he should type something that fits some format, like a postcode, or telephone number, or the house number in an address, or car registration sign

For this, consider to use a MaskedTextBox control.

在此处输入图像描述

With the MaskedTextBox you can easily define the format of some input string: how many characters, where do we want a Letter, and where a Digit? Where should brackets occur.

A MaskedTextBox control is just like an ordinary Textbox, only with a specific format. The Mask :

  • The "#" character in the mask is used for digit only
  • The "&" character accepts letter only
  • The "!" character accepts letter or digit
  • You can use any mask symbol, letter and digit other than # & and !

See the image what happens with certain formats.

The mask shows a predefined format what to expect: where do we want brackets, where do we want spaces, numbers, etc. The mask prevents typing incorrect characters.

The control notifies you when the operator has typed text that matches a complete mask.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM