I want to try a writing article, I wrote this article hoping to give C # beginners with a little prompt. I made a MSN style control in the morning, and I will take this as an example to teach you to do control. Let everyone feel that .NET brings us convenience. Experience the ability of his rapid development. Let's introduce the general structure of the control (as shown)
http://dongde.com/down/1.jpg,
BARS and PAGECOLLECTION Control BAR and Page for both collections, I will talk about some difficulties I have encountered, the first is the control is done, how to perform the interface without writing the code in myself. Design, this. Net has already prepared a good set of mechanisms. Just use it with it, I will refer to Microsoft's TabControl Writing. By setting attributes, you can add a selection card, my approach is [category ("Appearance")]
[Description ("Add a tab here")]
[DesignerIzationVisibility (DesignerSerizationVisibility.content)]
Public pageCollection PageSISITEM
{
get
{
Return this.pages;
}
}
[Category ("APPEARANCE")]]]]
Public Panel Bars
{
get
{
Return THISMYBARS;
}
}
Pay attention to this attribute [DesignerSerizationVisibility.content], what does it mean or you look at it?
The second difficulty is how to control the status of the control in the design means to teach the message to control the control. When will send the message to the designer to deal with, I don't have a success at this point, I am a message Give the control process, although trying accurate control but still has no control,
Protected Override Void WndProc (Ref System.Windows.Forms.MESSAGE M)
{
This.defwndProc (Ref M); // handle the message to the control, the disadvantage is that the designer cannot complete the function of the selection, but you drag or ok.
#Region Garbage
// switch (m.msg)
// {
// Case (int) msgs.wm_mousemove:
// this.defwndproc (Ref m);
// Break;
// Case (int) msgs.wm_lbuttondown:
// if (this.control! = Null)
// {
// int xpos = ((uint) m.lparam & 0x0000FFFU);
// int ypos = ((UINT) M.LPARAM & 0xFFFFFFFF0000U) >> 16);
// Rectangle Rect = New Rectangle (this.Control.Location, New Size (40, 100));
// if (Rect.Contains (XPOS, YPOS))
// {
// this.defwndproc (Ref m);
//}
// else
// {
// base.wndproc (Ref m);
//}
//}
// Break;
// Default:
// base.wndproc (Ref m);
// Break;
//}
#ndregion
Let's talk about how to use it, if you have used TabControl, it is easy to use my control, and you can use the PageItem property, and the page's barImage property. It's okay to be made close to the perfect control. It is the convenience of the end. Just add it to the toolbox, you don't need to write some complex code every time, doing the control is easy,