Input provides various properties for customizing the appearance and styling the Masked Textbox control, so that you can generate the MaskedTextBox control as per your requirement and change the look and feel of the application you are creating.
The C1MaskedTextBox class allows you to enhance the appearance of the TextBox control, such as changing the forecolor, adding an icon or placeholder etc.
The code snippet below depicts how to use appearance-related properties in Masked Textbox:
C# |
コードのコピー
|
---|---|
// MaskedTextboxの外観を変更します c1MaskedTextBox1.ForeColor = System.Drawing.Color.MediumSeaGreen; c1MaskedTextBox1.Icon = new C1.Framework.C1BitmapIcon(null, new System.Drawing.Size(16, 16), System.Drawing.Color.Transparent, Image.FromFile(@"resources\OIP (7).jpg")); c1MaskedTextBox1.Placeholder = "Enter phone number"; |
Let's explore how to use styling properties to style the UI of the Masked TextBox control.
The C1MaskedTextBox class provides the BackColor and ForeColor properties to set the background and foreground colors, respectively. Besides these, it also provides the Styles property to apply styling to different states of textbox such as Default, Disabled, Hot, HotPressed, and Pressed.
The following image showcases styling applied to the Masked TextBox control.
To apply styling to the Masked TextBox control, use the following code. Here, we apply styling to the Masked TextBox control by setting the background color, foreground color, font style and borders.
C# |
コードのコピー
|
---|---|
// MaskedTextbox をスタイル設定します c1MaskedTextBox1.BackColor = System.Drawing.Color.AntiqueWhite; c1MaskedTextBox1.Styles.Hot.BackColor = System.Drawing.Color.Yellow; c1MaskedTextBox1.ForeColor = Color.Purple; //フォントのスタイルを設定します c1MaskedTextBox1.Font = new System.Drawing.Font("Segoe UI", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point); //境界線を設定します c1MaskedTextBox1.Styles.Default.BorderColor = System.Drawing.Color.DarkOrange; c1MaskedTextBox1.Styles.Border = new C1.Framework.Thickness(2, 2, 2, 2); |