Francis Rubio
Francis Rubio

Reputation: 175

Customizing Borders on a TextBox

So I have a TextBox in my WinForm that I would want to design. I would like to achieve a text box that has no border except for its bottom part, just like the one in the Material Design Website:

enter image description here

But I have a few problems. I don't know how to code this one. Is there any way to code it like the one we use in CSS, i.e. border-bottom or something?

Upvotes: 2

Views: 4950

Answers (1)

Aethan
Aethan

Reputation: 1985

I was able to create a design near the one in your image but not in the way you want it.

Here's the one I managed to make:

Search

What I used:

  • textbox for the search input
  • label for clearing the input,
  • line shape (found in Visual Basic PowerPacks in the toolbox) for the border effect OR
  • another label having a long underscore ( _ ).
  • and a picturebox for the search icon

Procedure:

For the textbox, set these properties:

  • BorderStyle : None
  • BackColor: 0, 188, 212 (or the color of your form's background) but that's the exact color based on the image you provided
  • ForeColor: White

For the clear button, I just used a label (it still has a click event), set the text to: "✖" and the BackColor to Transparent.

For the border effect, just draw a line shape below the textbox then set:

  • BorderColor: White
  • BorderWidth to 3

If you are using the label with underscores, just place it under the textbox.

Sorry got bored that I even included everything even though you're just asking for the border (still wondering why did I answer this on the first place). I hope this can still be of any help.

Upvotes: 3

Related Questions