C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet1051/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   1047   1048   1049   1050   1051   1052   1053   1054   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

The Form Class

A form is created by instantiating an object of the 



Form

 class or of any class derived from 



Form

.

Form

 contains significant functionality of its own, and it inherits additional functionality. 

Two of its most important base classes are 



System.ComponentModel.Component

, which 


supports the .NET component model, and 

System.Windows.Forms.Control

. The 


Control

class defines features common to all Windows controls. Because 



Form

 inherits 



Control

, it, 


too,

is a control. This fact allows forms to be used to create controls. Several of the members of 



Form

 and 


Control

 are used in the examples that follow.



A Skeletal Form-Based Windows Program

We will begin by creating a minimal form-based Windows application. This application 

simply creates and displays a window. It contains no other features. However, this skeleton 

does show the steps necessary to construct a fully functional window. This framework is the 

starting point upon which most types of Windows applications will be built. The skeletal 

form-based Windows program is shown next.

www.freepdf-books.com



850

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

// A form-based Windows Skeleton.

using System;

using System.Windows.Forms;

// WinSkel is derived from Form.

class WinSkel : Form {

  public WinSkel() {

    // Give the window a name.

    Text = "A Windows Skeleton";

  }


  // Main is used only to start the application.

  [STAThread]

  static void Main() {

    WinSkel skel = new WinSkel(); // create a form

    // Enable visual styles.

    Application.EnableVisualStyles();

    // Start the window running.

    Application.Run(skel);

  }

}

The window created by this program is shown in Figure 26-1. Let’s examine this 



program line-by-line. First, notice that both 

System

 and 


System.Windows.Forms

 are 


included.

System

 is needed because of the 



STAThread

 attribute that precedes 



Main( )

.

System.Windows.Forms 

supports the Windows Forms subsystem, as just explained.

Next, a class called 



WinSkel

 is created. It inherits 



Form

. Thus, 


WinSkel

 defines a 

specific type of form. In this case, it is a minimal form.

Inside the 



WinSkel

 constructor is the following line of code:

Text = "A Windows Skeleton";

Text

 is the property that sets the title of the window. Thus, this assignment causes the title 

bar in the window to contain 

A Windows Skeleton

.

Text

 is defined like this:

public override string Text { get; set; }

F

IGURE


 26-1 

The skeletal form-

based window

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   1047   1048   1049   1050   1051   1052   1053   1054   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish