. Net WinForm user control development-(1) textbox Control with buttons

Source: Internet
Author: User

Today, let's take a look at the development of user controls in. net winform. This section shows you a textbox Control with underscores and buttons. Let's take a look!

The following shows how to implement such a user control.

1. Create a user control

Add a new project-User Control

2. Drag and Drop a label, textbox, And button on the user control.

And set the properties of the control as follows:

Textbox: Set the boderstyle attribute to none.

Button: Set the image of the button to a search image.

 

 

3. Compile the control, and then you can see the control in the toolbox. Then, place the control on the interface to see the effect.

 

Main Code:

[Csharp]
Public partial class UCLineTextBox: UserControl
{
Public UCLineTextBox ()
{
InitializeComponent ();
}
 
[Category ("Custom"), Description ("show text content")]
Public override string Text
{
Get
{
Return tb. Text;
}
Set
{
Tb. Text = value;
}
 
}
 
Public delegate void ButtonClick ();
Public event ButtonClick ButtonSelectClick;
 
Private void tb_Enter (object sender, EventArgs e)
{
// When the mouse enters the text box, the button is visible.
Btn. Visible = true;
}
 
Private void tb_Leave (object sender, EventArgs e)
{
// When the mouse leaves the text box, the button disappears
Btn. Visible = false;
}
 
Private void UCLineTextBox_Load (object sender, EventArgs e)
{
Btn. Visible = false;
}
 
Private void btn_Click (object sender, EventArgs e)
{
Try
{
ButtonSelectClick. DynamicInvoke (null );
}
Catch (Exception)
{

Return;
}
}
 
 
}
Author: zx13525079024

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.