C# 0 The Complete Reference


PART II C h a p t e r   2 6



Download 4,07 Mb.
Pdf ko'rish
bet1073/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   1069   1070   1071   1072   1073   1074   1075   1076   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 6 :  

U s e   S y s t e m . W i n d o w s . F o r m s  

865


    // Create File submenu.

    ToolStripMenuItem item1 = new ToolStripMenuItem("Open");

    m1.DropDownItems.Add(item1);

    ToolStripMenuItem item2 = new ToolStripMenuItem("Close");

    m1.DropDownItems.Add(item2);

    ToolStripMenuItem item3 = new ToolStripMenuItem("Exit");

    m1.DropDownItems.Add(item3);

    // Create Tools submenu.

    ToolStripMenuItem item4 = new ToolStripMenuItem("Coordinates");

    m2.DropDownItems.Add(item4);

    ToolStripMenuItem item5 = new ToolStripMenuItem("Change Size");

    m2.DropDownItems.Add(item5);

    ToolStripMenuItem item6 = new ToolStripMenuItem("Restore");

    m2.DropDownItems.Add(item6);

    // Add event handlers for the menu items.

    item1.Click += MMOpenClick;

    item2.Click += MMCloseClick;

    item3.Click += MMExitClick;

    item4.Click += MMCoordClick;

    item5.Click += MMChangeClick;

    item6.Click += MMRestoreClick;

    // Add to list of controls.

    Controls.Add(MyMenu);

    // Assign the menu to the form.

    MainMenuStrip = MyMenu;

  }


  [STAThread]

  static void Main() {

    MenuForm skel = new MenuForm();

    Application.EnableVisualStyles();

    Application.Run(skel);

  }


  // Handler for main menu Coordinates selection.

  void MMCoordClick(object who, EventArgs e) {

    // Create a string that contains the coordinates.

    string size =

      String.Format("{0}: {1}, {2}\n{3}: {4}, {5} ",

                    "Top, Left", Top, Left,

                    "Bottom, Right", Bottom, Right);

    // Display a message box.

    MessageBox.Show(size, "Window Coordinates",

www.freepdf-books.com




866

 

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

                    MessageBoxButtons.OK);

  }

  // Handler for main menu Change selection.



  void MMChangeClick(object who, EventArgs e) {

    Width = Height = 200;

  }

  // Handler for main menu Restore selection.



  void MMRestoreClick(object who, EventArgs e) {

    Width = Height = 300;

  }

  // Handler for main menu Open selection.



  void MMOpenClick(object who, EventArgs e) {

    MessageBox.Show("Inactive", "Inactive",

                    MessageBoxButtons.OK);

  }


  // Handler for main menu Close selection.

  void MMCloseClick(object who, EventArgs e) {

    MessageBox.Show("Inactive", "Inactive",

                    MessageBoxButtons.OK);

  }

  // Handler for main menu Exit selection.



  void MMExitClick(object who, EventArgs e) {

    DialogResult result = MessageBox.Show("Stop Program?",

                            "Terminate",

                             MessageBoxButtons.YesNo);

    if(result == DialogResult.Yes) Application.Exit();

  }


}

F

IGURE



 26-5 

Sample output 

from the 

MenuStrip

program

www.freepdf-books.com




A

Documentation Comment 

Quick Reference

C

# supports three types of comments. The first two are 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   1069   1070   1071   1072   1073   1074   1075   1076   ...   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