sstainba
April 13th, 2005, 12:04 PM
Is there any way to mask the characters in a multiline textbox? According to the MSDN, the "PasswordChar" and "UseSystemPassword" members are only good for single line controls. Can ya help me out?
Sam.
Sam.
|
Click to See Complete Forum and Search --> : Question about Textbox password char? sstainba April 13th, 2005, 12:04 PM Is there any way to mask the characters in a multiline textbox? According to the MSDN, the "PasswordChar" and "UseSystemPassword" members are only good for single line controls. Can ya help me out? Sam. darwen April 13th, 2005, 05:54 PM The only thing I can suggest is that you derive a class from the TextBox class and override OnPaint. Don't call base on this (which might have other implications, like some borders not being drawn) and get the TextBox::Text string and construct a string with all characters turned into '*', or whichever character you decide. Then you can draw them using the Graphics object in the PaintEventArgs. The DrawString method is what you want. Now, wrapping is a problem here. I presume you don't want spaces to appear as spaces in your 'obscured' string. Otherwise people might be able to guess the text. If not, then make sure spaces are preserved in the string you pass to the DrawString method and pass in the ClientRectangle property of the control. I hope this helps. Darwen. codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved. |