user12275552
user12275552

Reputation:

Custom textBox in C#

can anyone help me to creat a textBox with the bottom border only in C#? I'm using WinForms and .Net Framework 4.8. Here is the image that I want to create. I need the correct solution for this.

Image

Upvotes: 1

Views: 1931

Answers (2)

D J
D J

Reputation: 937

This specific Textbox that you mentioned by showing a picture is called Material TextBox and such an UI is called Material UI.

You can refer this link:

How to use material design controls c# winforms

The accepted answer will work perfectly fine however if you want something more professional, this could be your choice.

The link explains how to use the Nuget Package MaterialSkin.Updated in your winforms application to make a beautiful UI.

EDIT :

If you are not a coding geek and you need to do it without much coding part, you can create a simple user control with a textbox(design the backcolor and textcolour to suit your needs).

Then add a panel at the bottom with size (0,1) and set it to be visible only when the textbox gets focus.

This link provides examples to add placeholder to textboxes : Placeholder StackOverFlow

Upvotes: 0

teslae
teslae

Reputation: 239

One way to achieve this would be to dock a label to bottom of TextBox like so

textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
var label = new Label()
{
    Height = 1,
    Dock = DockStyle.Bottom,
    BackColor = Color.Black
};
textBox1.Controls.Add(label);

Upvotes: 2

Related Questions