This article demonstrates how to set a read-only object, but allows users to select it and set textbox of other attributes. Instead of using the readonly attribute, this article uses another tips.
Keywords
. NET Compact framework, Windows Mobile, Textbox, keypress, C #
The traditional textbox with readonly = true is not easy to modify, but lable does not allow users to select the content above. The keypress cannot be used to type the content. A simple technique is used to implement a textbox that is read-only but other attributes are available.
CodeAs follows:
Public Form1 ()
{
Initializecomponent ();
Textbox1.keypress+ = NewKeypresseventhandler (textbox1_keypress );
}
Void Textbox1_keypress ( Object Sender, keypresseventargs E)
{
E. Handled= True;
}
The running effect is as follows:
Complete example: Click here to download
Enjoy!
Yellow winter