Finally, I inherited it from system. Windows. Forms. Control.

Source: Internet
Author: User
A good web page, good, chat record, write down.

The essay published the day before, which records some resources. Due to the real access to. Net (WIN form ?) It's still relatively late, so it's still stupid till now, or it's just a second flight.

After carefully reading some resources, we finally made the first control to celebrate.

Using System;
Using System. Windows. forms;
Using System. componentmodel;
Using System. drawing;
Using System. Drawing. drawing2d;
Using System. Drawing. design;

Namespace Dividerpanel
{
/**/ /// <Summary>
///My first control.
/// </Summary>
[Toolboxitem ( True )]
[Toolboxbitmap ( Typeof (Myfirstcontrol)]
Public   Class Myfirstcontrol: system. Windows. Forms. Control
{

Private System. Drawing. drawing2d. graphicspath =   New Graphicspath (system. Drawing. drawing2d. fillmode. Alternate );

Private Color backcolor = Color. Black;

Public Myfirstcontrol ()
{
This . Graphicspath. addpolygon ( New Point [] {
New Point ( 10 , 0 ),
New Point ( 10 , 10 ),
New Point ( 0 , 10 ),
New Point ( 0 , 90 ),
New Point ( 10 , 90 ),
New Point ( 10 , 100 ),
New Point ( 190 , 100 ),
New Point ( 190 , 90 ),
New Point ( 200 , 90 ),
New Point ( 200 , 10 ),
New Point ( 190 , 10 ),
New Point ( 190 , 0 )
} );

This . Region =   New Region (graphicspath );
}

Private   Void Initializecomponent ()
{
}

Protected   Override   Void Onpaint (painteventargs E)
{
Lineargradientbrush B =   New Lineargradientbrush ( This . Clientrectangle,
This . Backcolor, This . Backcolor, 0 , False );

E. Graphics. fillrectangle (B, This . Clientrectangle );
}

Protected   Override   Void Ongotfocus (eventargs E)
{
Base. Ongotfocus (E );
This. Backcolor=Color. Red;
This. Invalidate ();
}

Protected   Override   Void Onlostfocus (eventargs E)
{
Base. Onlostfocus (E );
This. Backcolor=Color. Black;
This. Invalidate ();
}

Protected   Override   Void Onclick (eventargs E)
{
Base. Onclick (E );

This. Focus ();
}

}
}
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.