Simply record: dialog box controls and layout controls
dialog box:
First, the prompt dialog box:
DialogResult result = MessageBox.Show ("Hint text", "title text", button settings, icon settings)
if (result = = enumeration)
{
}
Second, other dialog box:
(a) ColorDialog:
1. Properties:
Color-The selected colors.
2. Method:
ShowDialog ()-Displays the Color dialog box. Returns a DialogResult object.
3, Case:
DialogResult result = Colordialog1.showdialog ();
if (result = = System.Windows.Forms.DialogResult.OK)
{
Label1. ForeColor = colorDialog1.Color;
}
(b) FontDialog:
1. Properties:
Font-selected fonts
2. Method:
ShowDialog ()-Displays the Font dialog box. Returns a DialogResult object
3. Case:
DialogResult result = Fontdialog1.showdialog ();
if (result = = System.Windows.Forms.DialogResult.OK)
{
Label1. Font = Fontdialog1.font;
}
(c) Openfiledialog,savefiledialog:
1. Properties:
FileName-The full name of the open file (including the path)
InitialDirectory-the initial path. Default in My Documents
Filter-turns on filtering. Display Name | wildcard name | display Name | Wildcard name such as: Text file |*.txt| C # source files |*.cs| All files |*.*
2. Method:
ShowDialog ()-Show open dialog box, return DialogResult
3. For example:
DialogResult result = Openfiledialog1.showdialog ();
if (result = = System.Windows.Forms.DialogResult.OK)
{
Label1. Text = Openfiledialog1.filename;
}
(iv) FolderBrowserDialog-Path selection dialog box
1. Properties
SelectedPath-The selected path.
RootFolder-The default open path.
Description-Prompt information in the dialog box
2. Methods
ShowDialog ()
3. For example
DialogResult result = Folderbrowserdialog1.showdialog ();
if (result = = System.Windows.Forms.DialogResult.OK)
{
Label1. Text = Folderbrowserdialog1.selectedpath;
}
Three, customize dialog box:
Make a form for you to display as a dialog box.
First step: Make dialog Box form
1. Make a form and make the function that you want to implement.
2. Put two buttons to set the DialogResult properties of the two buttons.
The second big step: Call the dialog box to display and get the value.
1. Give the dialog box form to new.
2. Use the ShowDialog () dialog box form to display it. Returns the DialogResult object
3. According to the returned DialogResult, determine the operation.
Testdialog td = New Testdialog ();
DialogResult result = TD. ShowDialog ();
if (result = = System.Windows.Forms.DialogResult.OK)
{
Label1. Text = TD. Password;
}
Layout:
First, the default layout (empty layout):
1.Location-Location
2.Anchor-Fixed margins
Second, the border layout:
Dock-upper right bottom left middle
Three, Grid layout:
The TableLayoutPanel control, which is used to format rows and columns.
Use the rowspan and colspan of the internally placed controls to set the control's cross-row and cross-columns.
Four, Flow-type layout:
The FlowLayoutPanel control. It has an important attribute: FlowDirection-the direction of the flow
Five, card layout:
The TabControl control. It contains multiple tabpage, which are placed in the TabPages collection.
Six, split layout:
The SplitContainer control. Splits the window horizontally or vertically.
Orientation-the direction of the split.
Windows Form-----Content (7)