Input provides various properties for customizing the appearance and styling the Input control, so that you can generate the TextBox control as per your requirement and change the look and feel of the application you are creating.
With the appearance-related properties, you can change the fore-color, and add background image and layout to a TextBox.
The code snippet below depicts how to enhance the appearance of the TexTbox control.
C# |
Copy Code
|
---|---|
// Change the appearance-related properties in TextBox c1TextBox1.Font = new System.Drawing.Font("Rockwell Extra Bold", 11F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point); c1TextBox1.ForeColor = System.Drawing.Color.RoyalBlue; c1TextBox1.Icon = new C1.Framework.C1BitmapIcon(null, new System.Drawing.Size(16, 16), System.Drawing.Color.Transparent, Image.FromFile(@"resources\OIP (2).jpg")); c1TextBox1.Location = new System.Drawing.Point(429, 433); c1TextBox1.Placeholder = "Add text..."; c1TextBox1.Size = new System.Drawing.Size(162, 54); |
The C1TextBox 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 Button control.
To apply styling to the TextBox control, use the following code. Here, we apply styling to the control by setting background color, foreground color, font style, and borders.
C# |
Copy Code
|
---|---|
// Change the styling-related properties in TextBox c1TextBox2.Location = new System.Drawing.Point(3, 87); c1TextBox2.Placeholder = "Add text..."; c1TextBox2.Size = new System.Drawing.Size(125, 26); c1TextBox2.Styles.Border = new C1.Framework.Thickness(2, 2, 2, 2); c1TextBox2.Styles.Button.Default.BackColor = System.Drawing.Color.Bisque; c1TextBox2.Styles.Button.Default.BorderColor = System.Drawing.Color.Crimson; c1TextBox2.Styles.Default.BackColor = System.Drawing.Color.Bisque; c1TextBox2.Styles.Default.BorderColor = System.Drawing.Color.Blue; c1TextBox2.Styles.Default.ForeColor = System.Drawing.Color.Tomato; c1TextBox2.Styles.Font = new System.Drawing.Font("Times New Roman", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); c1TextBox2.Styles.Hot.BackColor = System.Drawing.Color.Yellow; |
Alternatively, you can set the type of border for TextBox using BorderStyle property of the C1TextBox class. The value of the property can be set using the BorderStyle enumeration, which includes options such as None, FixedSingle, and Fixed3D. By default, the border style property is set to BorderStyle.FixedSingle. The image below showcases TextBox with its border style set to None.
The below code snippet illustrates setting the border style for TextBox to None.
C# |
Copy Code
|
---|---|
c1TextBox1.BorderStyle = BorderStyle.None; |