Home
Manage Your Code
Snippet: Form Class Members (C#)
Title: Form Class Members Language: C#
Description: Documented Memebrs of FORM Views: 115
Author: Johnny Rowe Date Added: 6/17/2008
Copy Code  
1
2// Add pre-defined Controls to the form.
3this.Controls.Add(button1);
4// Add button2 to the form.
5this.Controls.Add(button2);
6// Add Form to a pre-defined panel.
7panel1.Controls.Add(this);
8
9
10//FormBorderStyle  Gets or sets the border style of the form.
11//
12//Define the border style of the form to a FixedToolWindow
13this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
14//
15// Define the border style of the form to a dialog box.
16this.FormBorderStyle = FormBorderStyle.FixedDialog;
17
18
19//FormStartPosition   Gets or sets the starting position of the form at run time.
20//
21// Set the start position of the form to the center of the screen.
22form1.StartPosition = FormStartPosition.CenterScreen;
23
24
25
26//MaximizeBox   Gets or sets a value indicating whether the Maximize button is displayed in the caption bar of the form.
27//MinimizeBox	Gets or sets a value indicating whether the Minimize button is displayed in the caption bar of the form.
28//
29// Set the MaximizeBox to false to remove the maximize box.
30form1.MaximizeBox = false;
31// Set the MinimizeBox to false to remove the minimize box.
32form1.MinimizeBox = false;
33
34
35//Referencing Form Class by passing this on instantiation of class
36//
37//Field variable
38public Form2 MyToolWindow;
39//
40MyToolWindow = new Form2(this, panel1);
41//
42//Note: Class being called has receiving arguments as below in class constructor
43public Form2(Form referencingForm, Panel referencingPanel)
44
45
46//Show or ShowDialog means to display
47//
48// Display the form as a modal dialog box.
49form1.ShowDialog();
50
51
52//ShowInTaskbar using boolean
53//Gets or sets a value indicating whether the form is displayed in the Windows taskbar.
54this.ShowInTaskbar = false;
55
56
57//Text for title in form (leave propeties Text blank)
58//Gets or sets the text associated with this control. (Overrides Control..::.Text.)
59//In .NET Compact Framework 3.5, this member is inherited from Control..::.Text.
60this.Text = "TitleBar name here...";
61
62
63//TopLevel   Gets or sets a value indicating whether to display the form as a top-level window.
64this.TopLevel = false;
65