Bài giảng Lập trình C# 2010: Chương 2.2 - ĐH Công nghệ Đồng Nai

57 29 0
Bài giảng Lập trình C# 2010: Chương 2.2 - ĐH Công nghệ Đồng Nai

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Bài giảng Lập trình C# 2010: Chương 2.2 trình bày các nội dung tiếp theo của chương 2 về DateTimePicker & MonthCalendar, các thao tác cơ bản, nút lệnh và tính năng của nó, cách thức thực hiện cùng một số nội dung khác.

DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY DateTimePicker & MonthCalendar DONG NAI UNIVERSITY OF TECHNOLOGY Name Format Description Gets or sets the format of the date and time displayed in the control CustomFormat Gets or sets the custom date/time format string Value Gets or sets the date/time value assigned to the control dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"; Next Slide to see list Custom Format DONG NAI UNIVERSITY OF TECHNOLOGY Format string Description d dd ddd dddd h hh H The one- or two-digit day The two-digit day Single-digit day values are preceded by a The three-character day-of-week abbreviation The full day-of-week name The one- or two-digit hour in 12-hour format The two-digit hour in 12-hour format Single digit values are preceded by a The one- or two-digit hour in 24-hour format DONG NAI UNIVERSITY OF TECHNOLOGY Format string Description HH m mm M mm M MM MMM The two-digit hour in 24-hour format Single digit values are preceded by a The one- or two-digit minute The two-digit minute Single digit values are preceded by a The one- or two-digit month number The two-digit minute Single digit values are preceded by a The one- or two-digit month number The two-digit month number Single digit values are preceded by a The three-character month abbreviation DONG NAI UNIVERSITY OF TECHNOLOGY Format string Description MMMM s ss t The full month name The one- or two-digit seconds The two-digit seconds Single digit values are preceded by a The one-letter A.M./P.M abbreviation (A.M is displayed as "A") tt The two-letter A.M./P.M abbreviation (A.M is displayed as "AM") y The one-digit year (2001 is displayed as "1") yy yyyy The last two digits of the year (2001 is displayed as "01") The full year (2001 is displayed as "2001") DONG NAI UNIVERSITY OF TECHNOLOGY ListBox private void frm ListBox_Load(object sender, EventArgs e) { listBox1.Item s.Clear(); for (int i= 0; i< 10; i+ + ) listBox1.Item s.Add("Item " + i); } private void listBox1_SelectedIndexC hanged (object sender,EventArgs e) { lblM essage.Text = listBox1.Text + " w as clicked!"; } DONG NAI UNIVERSITY OF TECHNOLOGY A n d W e can u se A d d R an g e m eth od to ad d d ata: private void frm ListBox_Load(object sender, EventArgs e) { string[] strArr = new string[] { "Tèo","Tí","Bin","Bo"}; listBox1.Item s.AddRange(strArr); } p u b lic class C S tud ent { p rivate strin g m _strID ; p rivate string m _strN am e; p u b lic C S tud ent(string strID , string strN am e) { th is.m _strID = strID ; this.m _strN am e = strN am e; } p u b lic string ID { g et { retu rn this.m _strID ; } set { this.m _strID = value; } } p u b lic string N am e { g et { retu rn this.m _strN am e; } set { this.m _strN am e = value; } } } DONG NAI UNIVERSITY OF TECHNOLOGY using System Collections; A lso W e can u se D ataS ou rce to d isp lay d ata ArrayList arr = new ArrayList(); for(int i= 0;i< 10;i+ + ) {arr.Add(new CStudent("ID _"+ i,"N am e "+ i)); } listBox1.D ataSource = arr; listBox1.ValueM em ber = "ID "; listBox1.D isplayM em ber = "N am e"; DONG NAI UNIVERSITY OF TECHNOLOGY DONG NAI UNIVERSITY OF TECHNOLOGY m enuEdit.D ropD ow nItem s.AddRange(new ToolStripItem [] { m enuEditCut,m enuEditCopy, m enuEditPaste}); m enuBar.Item s.AddRange(new ToolStripItem [] { m enuFile,m enuEdit}); this.Controls.Add(m enuBar); attachEvents(); } private void attachEvents() {menuFileExit.Click += processClick; } DONG NAI UNIVERSITY OF TECHNOLOGY p rivate void p rocessC lick (object o, EventArgs e) { if (o.Equals(m enuFileExit)) Application.Exit(); } p rivate void frm M en u S trip _Load (object sender, EventArgs e) { createM enu(); } DONG NAI UNIVERSITY OF TECHNOLOGY ContextMenuStrip Drag & Drop into the FORM DONG NAI UNIVERSITY OF TECHNOLOGY ImageScalingSize to set Width, Height Icon Click Items (Collection) to add MenuItem DONG NAI UNIVERSITY OF TECHNOLOGY As the same MenuStrip DONG NAI UNIVERSITY OF TECHNOLOGY 1.Choose button 2.Set ContextMenuStrip 3.Attach event as the same MenuStrip DONG NAI UNIVERSITY OF TECHNOLOGY ToolStripContainer & ToolStrip DONG NAI UNIVERSITY OF TECHNOLOGY ToolStripContainer DONG NAI UNIVERSITY OF TECHNOLOGY ToolStripContainer Provides panels on each side of the form and a central panel that can hold one or more controls DONG NAI UNIVERSITY OF TECHNOLOGY Drag & Drop ToolStrip into the Form DONG NAI UNIVERSITY OF TECHNOLOGY As the same MenuStrip DONG NAI UNIVERSITY OF TECHNOLOGY Add Items Collection for ToolBar DONG NAI UNIVERSITY OF TECHNOLOGY Attach Events for each Item DONG NAI UNIVERSITY OF TECHNOLOGY Exercise: (for Student) Coding ContextMenuStrip & ToolStrip at Runtime DONG NAI UNIVERSITY OF TECHNOLOGY END ... three-character day-of-week abbreviation The full day-of-week name The one- or two-digit hour in 12-hour format The two-digit hour in 12-hour format Single digit values are preceded by a The one-... one- or two-digit minute The two-digit minute Single digit values are preceded by a The one- or two-digit month number The two-digit minute Single digit values are preceded by a The one- or two-digit... dd, yyyy - dddd"; Next Slide to see list Custom Format DONG NAI UNIVERSITY OF TECHNOLOGY Format string Description d dd ddd dddd h hh H The one- or two-digit day The two-digit day Single-digit

Ngày đăng: 08/05/2021, 12:20

Từ khóa liên quan

Mục lục

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Slide 20

Tài liệu cùng người dùng

Tài liệu liên quan