PDA

View Full Version : فرمت maskedTextBox



nasimnastaran
پنج شنبه 17 فروردین 1385, 15:10 عصر
با سلام !
من می خواستم از کنترل maskedTextBox در دات نت 2005 برای ورود تاریخ شمسی توسط کاربر استفاده کنم به همین خاطر از فرمت تاریخ ( 00/00/0000 )(shortdate)استفاده کردم که کاربر تاریخ شمسی را در آن وارد کند . حال میخواستم در این فرمت اگر کاربر در قسمت فرمت "ماه" عدد 13 را نوشت یا در قسمت "روز" عدد 32 را وارد کرد ، به کاربر خطا را نشان بده .
از راهنمائی تان متشکرم .

habedijoo
شنبه 19 فروردین 1385, 09:13 صبح
جهت استفاده از امکانات MaskedTextBox

Mask characters


Character Description
0 Required digit (0-9).
9 Optional digit or space. If left blank, a space is inserted automatically.
# Optional digit, space, or plus/minus symbol. If left blank, a space is inserted automatically.
L Required ASCII letter (a-z or A-Z).
? Optional ASCII letter.
& Required Unicode character. Allows anything that isn't a control key, including punctuation and symbols.
C Optional Unicode character.
A Required alphanumeric character (allows letter or number but not punctuation or symbols).
a Optional alphanumeric character.
. Decimal placeholder.
, Thousands placeholder.
: Time separator.
/ Date separator.
$ Currency symbol.
< All the characters that follow will be converted automatically to lowercase as the user types them in. (There is no way to switch a subsequent portion of the text back to mixed-case entry mode once you use this character.)
> All the characters that follow will be converted automatically to uppercase as the user types them in.
\ Escapes a masked character, turning it into a literal. Thus, if you use \& it is interpreted as a literal character &, which will be inserted in the text box.
All other characters All other characters are treated as literals, and are shown in the text box.



بعضی از مهمترین خواص این کنترل :


BeepOnError
If the user inputs an invalid character and BeepOnError is TRue, the MaskedTextBox will play the standard error chime.

PromptChar
When the text box is empty, every required value is replaced with a prompt character. By default, the prompt character is the underscore (_), so a mask for a telephone number will display (_ _ _)-_ _ _-_ _ _ _ while empty.

MaskCompleted
Returns TRue if there are no empty characters in the text box (meaning the user has entered the required value).

InputText
InputText returns the data in the MaskedTextBox without any literal characters. For example, in a MaskedTextBox that allows the user to enter a telephone number, the Text property will return the fully formatted number, like (123)-456-7890, while InputText returns just the numeric content, or 1234567890.

nasimnastaran
شنبه 19 فروردین 1385, 23:15 عصر
با سلام و تشکر از پاسختان ,
من قسمت چگونگی دادن خطا به کاربر را متوجه شدم ، اما اشکال کار این است که فرمت آن به صورت mm/dd/yyyy آنهم تاریخ میلادی می باشد ، به عنوان مثال برای ماه دوم ، تا 29 روز را قبول می کند ، در صورتی که من می خواهم کاربر با فرمت dd/mm/yyyy آنهم تاریخ شمسی را داخل این کنترل قرار دهد .
با تشکر

habedijoo
یک شنبه 20 فروردین 1385, 08:58 صبح
مثالت رو بزار تا ببینمش .

nasimnastaran
یک شنبه 20 فروردین 1385, 14:34 عصر
با سلام ,
فایل پیوست می باشد .

habedijoo
یک شنبه 20 فروردین 1385, 16:17 عصر
دوست عزیز


Mask = ####/##/##

nasimnastaran
یک شنبه 20 فروردین 1385, 17:43 عصر
میشه لطف کنید بگید ، این فرمت برای تاریخ است یا چیز دیگر ، و اگر تاریخ است چه جوری میشه پیام Error را برای تاریخ شمسی به کاربر داد ؟( در صورتیکه کاربر ماه یا روز را اشتباه وارد کند ) .
با تشکر

habedijoo
دوشنبه 21 فروردین 1385, 14:30 عصر
ببین دوست عزیز توی باید تاریخ وارد شده رو بصورت رشته بگیری و خودت اونو با تابع درونی دات نت تبدیل به فرمت تاریخ کنی . در حین این کار صحت تاریخ برای شما مشخص میشه .
در ضمن میتونی کی تابع هم خودت بنویسی که این کار رو برات انجام بده .
این فرمتی که من نوشتم ساختار رشته ورودی را برات مشخص میکنه .

nasimnastaran
سه شنبه 22 فروردین 1385, 19:29 عصر
با تشـــــکر