First, let's take a look at statusstrip. The first choice is statusstrip, a control in form. It is also a big control at the same time. It contains many child controls, which are stored in the control group.
So when we use statusstrip, we must first define statusstrip, then define the toolstrip control, define the toolstrip control group again, and third Add the toolstrip control to the control group, fourth, add the control group to statusstrip, and finally add statusstrip to the window.
Example:
In this example, add a role in the Form window, and show "test" on the left side of the role 」.
1. In design mode, add the following method:
Add a statusstrip control to the window. Add a toolstriplabel control on statusstrip. Set the text sensitivity of the toolstriplabel control to the message displayed during running (that is, test ).
2. In the substitution mode, add the process as follows:
1. Define statusstrip
2. Define the control (toolstriplabel)
3. Define the control group (toolstripitem)
4. Add controls to the control group (items. addrange)
5. Add statusstrip to form
Public Form1 ()
{
Initializecomponent ();
# RegionAddstatusstrip
//1.Define the statusstrip to be added
Statusstrip sb= NewStatusstrip ();
//2. Defines controls in the statusstrip project. The toolstriplabel is a label-like control, which is used to display text.
Toolstriplabel TSL = New Toolstriplabel ();
// Text content to be displayed
TSL. Text = " Test " ;
// 3. define a project in statusstrip
toolstripitem [] TSI = New toolstripitem [ 1 ];
TSI [ 0 ] = TSL;
//4.Add a category to statusstrip
SB. Items. addrange (TSI );
//5.Add statusstrip to the form
This. Controls. Add (SB );
# Endregion
}
Result: