Bài giảng Lập trình Windows - Chương 3: Lập trình C# trên Windows

Tóm tắt Bài giảng Lập trình Windows - Chương 3: Lập trình C# trên Windows: ...ublic enum DialogResult { None, OK, Cancel, Abort, Retry, Ignore, Yes, No }Lớp FormKhái niệmLớp Form thể hiện một cửa sổ (window) hay một dialog box tạo nên giao diện của ứng dụngThông thường tạo custom form bằng cách thừa kế từ FormNamespaceSystem.Windows.FormAssembly:System.Windows.Form (S...à RadioButtonCheckBoxPropertiesText – chữ hiện kế bên checkboxChecked Checked = true –check box đã được checkChecked = false –check box chưa được checkEvents CheckedChanged – sự kiện phát sinh khi thay đổi trạng thái check CheckBoxCác dạng khác của CheckBoxThreeState = true: CheckBox có 3 trạng thái...ex = vị tríTreeViewExpand và collapsTree ExpandAll() CollapseAll() Node Collapse(), Expand(), ExpandAll(), Toggle(). TreeViewMột số properties khác của TreeViewCheckBoxes = boolFullRowSelect = boolIndent = numberShowLines, ShowPlusMinus, và ShowRootLinesSorted = boolMột số properties khác của TreeNo...

pptx220 trang | Chia sẻ: havih72 | Lượt xem: 213 | Lượt tải: 0download
Nội dung tài liệu Bài giảng Lập trình Windows - Chương 3: Lập trình C# trên Windows, để tải tài liệu về máy bạn click vào nút DOWNLOAD ở trên
 property CheckState để kiểm tra nó có là một trong 3 trạng tháiCheckedUnchecked Indeterminate Radio ButtonsRadio buttons tương tự checkbox, tuy nhiênCác button trong cùng nhóm chỉ có một button được check tại một thời điểmMột nhóm: Các radio button được đặt trong cùng container – thường là panel hay group boxRadio ButtonsProperty Checked – Cho biết button có được check hay khôngEvent CheckedChanged – Sự kiện phát sinh khi check box được check hay không được checkList ControlsList ControlsCó 3 list controlsListBox CheckedListBox ComboBox Lớp cơ sở: thừa kế từ lớp trừu tượng ListControlList ControlsPropertiesItems – danh sách các item có trong listSorted = true: tự động sắp xếp theo từ điểnSelectedIndex, SelectedIndices, SelectedItem, SelectedItems và Text – cung cấp các cách khác nhau để truy cập các mục đã chọnMethodsint FindString(string s) – tìm chuỗi s có trong list hay không EventsSelectedIndexChangedList ControlsThêm item vào item listlistName.Items.Add(“”);listName.Items.AddRange(String []);Chèn item vào item listlistName.Items.Insert(index, data);Xóa:listName.Items.Remove(data);listName.Items.RemoveAt(index);listName.Items.Clear();Tìm kiếmlistName.Items.Indexof(object obj);ListBoxListBox control cho phép hiển thị danh sách các mục để user chọn PropertiesMultiColumn – chia list thành các cột khi dữ liệu không hiển thị hết một lúc trên listSelectionMode – quy định chế độ chọn các mục trong list TopIndex – Cuộn ListBox đến TopIndexMethodsvoid ClearSelected()bool GetSelected(int index) void SetSelected(int index, bool value)ComboBox=LISTBOX+TEXTBOXComboBox control cho phép hiển thị danh sách các mục dạng drop down để user chọn PropertiesMaxDropDownItems, DropDownStyleMethodsvoid Select(int start, int length)void SelectAll()EventsDropDownCheckedListBoxCheckedListBox control – Hiện danh sách các checkboxPropertiesCheckedItems và CheckedIndices – truy cập mục đã chọnMultiColumn – chia list thành các cột khi dữ liệu không hiển thị hết một lúc trên listSelectionMode – quy định chế độ chọn các mục trong listTopIndex – Cuộn CheckedListBox đến TopIndexCheckedListBoxMethodsvoid ClearSelected()bool GetSelected(int index) void SetSelected(int index, bool value)bool GetItemChecked(int index)CheckState GetItemCheckState(int index)void SetItemChecked(int index, bool value)void SetItemCheckedState(int index, CheckState value) EventsItemCheckCheckedListBoxList ControlsBài tập luyện tậpLàm thế check hay unchecked tất cả các mục trong CheckListBoxLàm thế nào mặc nhiên chọn item đầu tiên trong ComboBoxCuộn Listbox hay ChecklistBox sao cho thấy được mục vừa mới thêm gần nhấtData binding Có thể kết nối control với dữ liệu thông qua property DataSource vớiDataSet, Mảng (tĩnh và động)Ví dụ:string[] cityChoices = {	"Seattle", "New York", 	"Signapore", "Montreal"}; lstCity.DataSource = cityChoices; Data bindingItems trong list control là một tập các object.Chú ý: Để hiển thị item trong trong list, list control gọi phương thức ToString()  Có thể kết hợp các đối tượng thuộc các lớp tự tạo với list control ImageListImageListImageList là một kiểu collection đặc biệt chứa các ảnh có kích thước và độ sâu màu được xác định trước. Các control khác nếu có hổ trợ dùng ImageList thì dùng các ảnh trong ImageList thông qua chỉ mục.ListView, TreeView, ToolBar, Button, PropertiesImages – collection các ảnhImageSize – kích thước của các ảnhTransparentColor – Định nghĩa màu trong suốtMethodDraw() Vẽ ảnh lên bề mặt GDI+ImageListThêm/xóa/sắp xếp các ảnh trong ImageListCách 1: Dùng Designer để thêm các ảnh (bmp, jpg, ico, ) vào Click () kế bên thuộc tính Image trong PropertiesImageListThêm/xóa/sắp xếp các ảnh trong ImageListChú ý: các file ảnh được thêm vào resource file khi dùng designerCách 2: Nạp các file ảnh từ file vào ImageListImageListImageList iconImage = new ImageList();// Cấu hình ImageListiconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; iconImages.ImageSize = new System.Drawing.Size(16, 16);// Lấy các file trong thư mục hiện tại string[] iconFiles = Directory.GetFiles(Application.StartupPath,	"*.ico"); // Thêm vào ImageListforeach (string iconFile in iconFiles) { 	Icon newIcon = new Icon(iconFile);	iconImages.Images.Add(newIcon); }ListView và TreeViewListViewListViewListview là control dùng để trình bày danh sách các mục mà có thể trình bày bằng 1 trong 4 cách khác nhauCác item trong ListView là một đối tượng ListViewItemListText có icon nhỏText có icon lớnDetailsTileListViewListViewListViewPropertiesItems – Một collection các đối tượng ListViewItem được hiển thị trong ListViewColumns – Một collection các đối tượng ColumnHeader được dùng trong Details ViewSelectedItems, SelectedIndicesLargeImageList = imageList objectSmallImageList = imageList objectMultiSelect = boolView: LargeIcon, SmallIcon, List, Details, Tile Sorting = Acending/DescendingFullRowSelect = boolListViewMethodsListViewItem GetItemAt(int x, int y) – lấy item tại (x,y)void Clear() – Xóa các item và các cột EventsColumnClick, ItemCheck ListViewThêm một item đơn giảnListViewItem item = new ListViewItem(string);listView.Items.Add(item);Thêm item có ảnhTạo imagelistGán imagelist cho LargeImageList/SmallImageListitem.ImageIndex=chỉ số hình trong imagelistThêm item có nhiều subitemstring[] data = {string1, string2, };ListViewItem item = new ListViewItem(data);listView.Items.Add(item);ListViewNhận dữ liệu trên ListViewListViewItem item = lstSignature.SelectedItems[0];string sub1 = item.SubItems[0].Text;string sub2 = item.SubItems[1].Text;Tạo detailView: DetailGridLines: trueColumns: Thêm các columnListViewListText có icon nhỏText có icon lớnDetailsCác loại Viewcủa ListViewTileListViewThay đổi ViewlistView.View = View.SmallIconSmallIconLargeIconDetailsListTileChú ý: Details phải có columnListViewMột số properties khácAllowColumnReorderAutoArrange CheckBoxes, CheckedIndices, CheckedItems GridLinesMột số methods khácBeginUpdate(), EndUpdate()TreeViewTreeView là một collection các node dạng phân cấpCác node trong cây thuộc lớp TreeNode, có thể được lồng không giới hạn. TreeViewPropertiesNodesSelectedNode, ShowRootLines , ImageIndex, ShowPlusMinus MethodsExpandAll(), GetNodeAt(), GetNodeCount(), CollapseAll() EventsAfterCheck, AfterCollapse, BeforeCheck, BeforeCollapse, AfterSelect, AfterExpand, BeforeSelect, BeforeExpand TreeViewThêm một nodeCách 1: tree.Nodes.Add(string);Cách 2:TreeNode newNode = new TreeNode(); newNode.Text = “"; newNode.Tag = “"; tree.Nodes.Add(newNode);TreeViewCấu trúc TreeViewCác nodes có thể lồng nhiều cấpThêm node con:Tìm node chaThêm node con vào node chaVí dụ 1 TreeNode node;node = tree.Nodes.Add(“cha”);node.Nodes.Add(“con”);TreeViewCấu trúc TreeViewVí dụ 2:TreeNode[] nodes = new TreeNode[n]; nodes[0] = new TreeNode(“cha”);nodes[0].Nodes.Add(“con”);tree.Nodes.AddRange(nodes);Ví dụ 3:	tree.BeginUpdate();		tree.EndUpdate();TreeViewDuyệt các phần tử của TreeView: 2 kỹ thuật cơ bảnDùng kỹ thuật đệ quyvoid XuLyCacNode(TreeNodeCollection nodes){	foreach (TreeNode node in nodes)	{	// Xử lý node	XuLyCacNode (node.Nodes)	}}TreeViewDuyệt các phần tử của TreeView: 2 kỹ thuật cơ bảnDùng các properties của nodeParentFirstNodeLastNodePrevNodeNextNodeTreeViewDuyệt các phần tử của TreeView: 2 kỹ thuật cơ bảnDùng các properties của nodevoid XuLyCacNode(TreeNode node){	do 	{	// Xử lý node	if (node.Nodes.Count>0)	XuLyCacNode(node.FirstNode);	node = node.NextNode;	} while (node != null);}TreeViewThao tác trên treeviewXóa node: Remove()Tham chiếu đến node cần xóa: Xóa nodeTìm vị trí node: xóa node tại vị trí đóXóa các node: Clear()Tìm kiếm vị trí: IndexOf()TreeViewNode ảnhẢnh cho toàn TreeViewtree.ImageList = imageList;tree.ImageIndex = vị tríẢnh cho từng nodetree.ImageList = imageList;node.ImageIndex = vị trínode.SelectedImageIndex = vị tríTreeViewExpand và collapsTree ExpandAll() CollapseAll() Node Collapse(), Expand(), ExpandAll(), Toggle(). TreeViewMột số properties khác của TreeViewCheckBoxes = boolFullRowSelect = boolIndent = numberShowLines, ShowPlusMinus, và ShowRootLinesSorted = boolMột số properties khác của TreeNodeChecked = boolIsSelected = boolIsExpanded = boolNumericUpDown, DomainUpDown, TrackBar và HScrollBar, VScrollBarNumericUpDown và DomainUpDownNumericUpDownNumericUpDown control cho phép chọn một số (nguyên/thực) trong miền giới hạnPropertiesMaximum, Minimum – Giá trị lớn nhất và nhỏ nhất có thể chọnIncrement – Bước nhảy mỗi lần clickDecimalPlaces – Số chữ số lẻValue – Giá trị hiện tại của controlMethodsvoid DownButton()void UpButton() EventsValueChanged – Sự kiện xảy ra khi value thay đổiDomainUpDownDomainUpDown cung cấp một danh sách các option (tương tự như List control), nhưng người dùng chỉ có thể chọn các item thông qua up/down button PropertiesTextSelectedIndexSelectedItemItemsMethodsvoid DownButton()void UpButton()DomainUpDownThêm chuỗi vào DomainUpDown// Add ItemsudCity.Items.Add("Tokyo"); udCity.Items.Add("Montreal"); udCity.Items.Add("New York"); Chọn item đầu tiênudCity.SelectedIndex = 0; TrackBarTrackBar cho phép người dùng chọn giá trị số nguyên một cách đồ họa dùng Tab acrossPropertiesMaximum, MinimumValueTickFrequencySmallChange, LargeChangeEventsValueChangedScroll HScrollBar và VScrollBarPropertiesValue: intMaximun: intMinimum: intSmallChange: intLargeChange: int RightToLeft: RightToLeftYesNoEventsScroll, ValueChanged HScrollBar và VScrollBarBài tập luyện tậpViết chương trình chỉnh sửa màu có giao diện như sauProgressBarProgressBarProgressBarProgressBar cho phép hiển thị tiến trình hoạt động của chương trìnhPropertiesStep – Bước nhảy mỗi lầnMaximum, Minimum – Giá trị lớn nhất và nhỏ nhất Value – Giá trị hiện tạiPhương thứcvoid PerformStep() – Tăng một lượng Stepvoid Increment(int value) – Tăng một lượng valuePictureBox và BitmapPictureBoxPictureBoxPropertiesImage – Lưu trữ hình đang hiện trên PictureBox*.gif, *.jpg, *.jpeg, *.bmp, *.wmf, *.png, *.tiffSizeMode – Kiểu enum PictureBoxSizeModeAutoSizeCenterImageNormalStretchSizeZoomEventsSizeModeChangedPictureBoxNạp ảnh từ filestring path = “”;Bitmap bitmap = new Bitmap(path);pic.Image = bimap;pic.SizeMode=PictureBoxSizeMode.StretchImage;BitmapImageBitmapMetafileBitmapBitmap bao bọc GDI+ bitmap: gồm dữ liệu pixel và các thuộc tính của bitmapPropertiesWidth,Height, Size – chiều rộng, chiều cao ảnh (pixel)Methodsvoid GetPixel(int x, int y)void SetPixel(int x, int y, Color color)void RotateFlip(RotateFlipType rotate);Save(string fileName)Save(string fileName, ImageFormat format)PictureBox và BitmapBài tập luyện tậpViết chương trình xử lý ảnh cơ bản, gồm những chức năng cơ bản sauChọn file ảnh, Lưu ảnhQuay ảnhHiện thị thông tin của ảnhCách hiện thị ảnh (SizeMode)Lấy màu tại vị trí chuột trên ảnhMaskedTextBox và RichTextBoxMaskedTextBox và RichTextBoxMaskedTextBoxRichTextBoxMaskedTextBoxMaskedTextBox là mở rộng của TextBox control bằng cách dùng một mặt nạ (Mask) để hướng dẫn nhập dữ liệu đúng đắnYêu cầu phải nhập hay Option Kiểu dữ liệu mong đợi tại vị trí cụ thểChú ý: MaskedTextBox không hổ trợ Multiline và UndoMaskedTextBoxPropertiesMask: string Methods void ResetText() – Thiết lập default textvoid Copy(), Cut(), Paste()MaskedTextBoxMask0 – phải nhập số ([0..9])9 – số hay space (option)L – phải nhập ký tự chữ ([a-zA-Z])? – ký tự chữ (option)& – phải nhập ký tự ascii C – nhập ký tự ascii (option)A – phải nhập Alphanumeric a – nhập Alphanumeric (option)MaskedTextBoxMask. – thập phân, – phân cách phần ngàn: – phân cách thời gian/ – phân cách ngày$ – ký hiệu tiền tệ – chuyển sang chữ HOA\ – Escape (\\ là \)MaskedTextBoxVí dụ00/00/0000 – ngày(999)-000-0000 – số điện thoại Mỹ$999,999.00 – tiền từ 0 đến 999999RichTextBoxPropertiesText: string – Văn bản trong RichTextBox Rtf: string – Code của văn bản SelectionText, SelectionRtf: string – Một phần văn bản hay code của văn bản được chọnSelectionColor, SelectionBackColor : Color văn bản được chọnSelectionFont: Font – font của văn bản được chọnRedoActionName – Lấy tên action khi phương thức Redo() gọiUndoActionName – Lấy tên action khi phương thức Undo() gọiZoomFactor – Mức zoomRichTextBoxMethodsvoid LoadFile(string path)void SaveFile(string path)void Redo()void Undo()void Copy() void Cut()void Paste()void Clear() – Xóa tất cả các textvoid SelectAll() – Chọn tất cả các textint Find(string string str)EventsLinkClicked, SelectionChanged RichTextBoxBài tập luyện tậpViết chuơng trình soạn thảo văn bản có định dạng như MS.WordDateTimePicker, MonthCalendervà TimerDateTimePicker, MonthCalender và TimerDateTimePickerMonthCalenderTimerDateTimePicker và MonthCalenderChọn một ngàyChọn một vùng ngày DateTimePickerMonthCalenderDateTimePickerDateTimePicker cho phép user chọn một ngàyPropertiesText, Value: Text trả về chuỗi ngày đã được định dạng, Value trả về đối tượng DateTimeFormat: định dạng hiển thịlong, short, time, customCustomFormat:dd/mm/yyyy: Ngày/Tháng/Nămhh:mm:ss: Giờ:Phút:GiâyMinDate, MaxDate : Chỉ ra vùng ngày user có thể chọnMonthCalenderMonthCalender cho phép user chọn một số ngày trong thángPropertiesSelectionStart, SelectionEnd: trả về các ngày đã chọnSelectionRange: cấu trúc chứa SelectionStart và SelectionEndMaxDate, MinDate, MaxSelectionCount: ngày tối đa và tối thiểu được chọn trong calender, và số ngày liên tục có thể chọn tại một thời điểmTimerTimer sinh ra sự kiện Tick theo định kỳ PropertiesInterval: int – thời gian sự kiện xảy ra (tính bằng millisecond)Enabled: bool – Cho phép timer start hay stopMethodsvoid Start() – Start timervoid Stop() – Stop timerEventsTickMenu, Toolbarvà StatusbarMenu và ToolbarMenuMột menu gồm 2 phần: Các mục menu (Item) và bộ chứa các mục menu (Container)Container: Lớp MenuStripItems – Chứa các MenuItem/TextBox/ComboBoxVisible – Ẩn hiện menuTextDirection – Hướng vẽ text trên itemLayoutStyle – Cách hiển thị menuCác mục menu: Lớp ToolStripMenuItemTextVisibleShortcutKeysShowShortcutKeys CheckedLớp ToolStripTextBoxLớp ToolStripComboBoxMenuTự thiết kế menuHotKey: thêm ký tự & trước ký tự muốn làm hot keyĐánh tên các mục menuMenuThêm menu chuẩnClick vào ký hiệu tam giác  Insert Standard ItemsMenuTạo Shortcut keyChọn mục menuVào properties thiết lập ShortcutKeysMenuCác loại menu itemMenuItemComboBoxTextBoxSeparatorChú ý: Click mũi tên xuống tại nơi muốn tạo menu item để chọn các loại menu itemMenuXử lý sự kiện:Xử lý sự kiện cho từng mục menu itemClick DoubleClickCheckedChangedCheckStateChangedContext menuContext menu là menu ngữ cảnh xuất hiện tại các control khi click phải chuột lên control đó để trợ giúp user hiểu về controlContainerContextMenuStripCác bước tạo Context menuB1: Tạo ContextMenuStripB2: Vào Properties của control muốn có menu ngữ cảnh: gán ContextMenuStrip bằng contextmenu đã tạo ở B1B3: Xử lý các sự kiện trên các menu item của Context menuToolBarToolBar chứa tập các nút có những chức năng khác nhauContainer: Lớp ToolStripCác item: LớpToolStripSplitButtonToolStripDropDownbuttonToolStripLabelToolStripProgressBarToolStripSeparatorToolStripComboBoxToolStripTextBoxToolBarCác loại ItemToolBarCác bước tạo toolbarB1: Tạo container: Kéo ToolStrip vào formB2: Tạo các itemChọn loại itemChọn hìnhB3: Xử lý các sự kiện cho các itemStatusBarContainer: StatusStripCác loại itemNotifyIcon và ToolTipNotifyIcon và ToolTipNotifyIconToolTipNotifyIconNotifyIcon dùng để tạo một icon trên System TrayPropertiesBalloonTipIcon: ToolTipIconBalloonTipText: stringBalloonTipTitle: stringContextMenuStripIcon: IconText: stringMethodsvoid ShowBalloonTip(int timeout)void ShowBalloonTip(int timeout, string title, string text, ToolTipIcon icon)ToolTipToolTip một công cụ trợ giúp user hiểu rõ các control trên form. ToolTip sẽ hiển thị một text khi user rê chuột vào control ToolTipPropertiesInitialDelay: intAutomaticDelay: int ShowAlways: boolBackColor, ForeColor: ColorToolTipTitle: stringToolTipIcon: ToolTipIcon.(Error, Info, None, Warning)EventsGetToolTip, SetToolTip, RemoveAllToolTipCác bước tạo tooltipB1: Kéo ToolTip vào form và thiết lập các propertiesB2: Chọn control muốn có propertiesB3: Vào properties nhập dòng văn bản tại: “ToolTip on têntooltip”Grouping ControlsGrouping ControlsCác loại Grouping ControlsFormPanelGroupBoxTab ControlForm, Panel, GroupBoxPropertiesEnabled: boolSize: SizeVisible: boolMethodsvoid Focus()void Refresh()EventsEnterLeavePaintGroupBoxHiện border xung quanh nhóm các controlProperty Text – gán Text label cho GroupBoxControl có thể được thêm vàoĐặt control vào trong GroupBox khi thiết kếViết codePanelPanel giống GroupBox nhưng không có text labelPanel chứa một các control như GroupBoxBorderStyle – get/set border style nhưBorderStyle.Fixed3DBorderStyle.FixedSingleBorderStyle.NoneTabControlPropertiesTabPagesSelectedTabShowTooltips , Multiline, TabCount, SelectedIndex EventsSelectedIndexChangedCác dialog thông dụngCác dialog thông dụngCác loại DialogCustom Dialog BoxesCommon Dialog BoxesOpenFileDialogSaveFileDialogFontDialogColorDialogFolderBrowserDialogPageSetUpDialogPrintPreviewDialog PrintDialogCác dialog thông dụngBốn bước sử dialogCấu hình dialog (thiết lập các properties)Hiện dialog bằng phương thức ShowDialog()Xác định người dùng nhấn OK hay Apply (đựa trên kiểu trả về DialogResult)Viết code thực hiện dựa trên hành động của user trên dialogCác dialog thông dụng: OpenFileDialogOpenFileDialog dùng để chọn một file để mở ra xử lýPropertiesFileName: stringFileNames: string[]Filter: stringCác dialog thông dụng: OpenFileDialogPropertiesDefaultExt: stringAddExtension: boolTitle: stringIntialDirectory: stringShowReadOnly: boolReadOnlyChecked: boolMultiSelect: boolMethodsDialogResult ShowDialog()Stream OpenFile()Các dialog thông dụng: SaveFileDialogSaveFileDialog dùng để chọn/nhập một file để lưu nội dung lên đĩaCác dialog thông dụng: SaveFileDialogPropertiesOverwritePrompt: boolFileName: stringFileNames: string[]Filter: stringDefaultExt: stringAddExtension: boolTitle: stringIntialDirectory: stringMethodsStream OpenFile()DialogResult ShowDialog()Các dialog thông dụng: FontDialogFontDialog dùng để chọn font chữ có trên máyCác dialog thông dụng: FontDialogPropertiesFontColorMaxSize, MinSizeShowColor: boolShowApply: boolShowEffects: boolMethodsDialogResult ShowDialog()void Reset()Các dialog thông dụng: ColorDialogColorDialog dùng để chọn màu có trên máyCác dialog thông dụng: ColorDialogPropertiesColorAllowFullOpen: bool FullOpen: boolMethodsDialogResult ShowDialog()void Reset()Các dialog thông dụng: FolderBrowserDialogFolderBrowserDialog dùng để chọn thư mục có trên máyCác dialog thông dụng: FolderBrowserDialogPropertiesDescription: stringRootFolder: Environment.SpecialFolderSelectedPath: stringShowNewFolderButton: boolMethodsDialogResult ShowDialog()void Reset()MDITạo MDITạo Form chaIsMdiContainer = trueTạo form conTạo object form con: 	ChildFormName f = new ChildFormName()f.MdiParent = this;f.Show();Tìm các form trong MDITìm form con đang activethis.ActiveMdiChild Tìm form chathis.MdiParentTìm các form conthis.MdiChildrenĐồng bộ dữ liệuChú ý: Form cha lưu các form conMỗi form con lưu 1 form chaĐồng bộ dữ liệu giữa các form conB1: Con gởi message nhờ form cha đồng bộ dữ liệuB2: Form cha duyệt các form con để đồng bộ dữ liệuSắp xếp các form conTạo menu item chứa danh sách form conTạo menu itemThiết lập MdiWindowListItem của menu container = menu item trênSắp xếp các form conthis.LayoutMdi(MdiLayout.ArrangeIcons);Cascade, TileHorizontal, TileVerticalMinimize các form conDuyệt các form con: this.MdiChildren Thiết lập thuộc tính: WindowState = FormWindowState.Minimized Đọc file dữ liệu văn bảnFile văn bảnNamespaceSystem.IOClass cơ bảnStreamReaderStreamWriterFile văn bảnĐọc file văn bảnStreamReader sr = new StreamReader(path);string data = sr.ReadLine();sr.Close();Một số lệnh hay dùngsr.EndOfStreamstring data = sr.ReadToEnd();int data = sr.Peek();File văn bảnGhi file văn bảnStreamWriter sw = new StreamWriter(path);sw.WriteLine();sw.Close();Một số lệnh hay dùngsw.Write();Một số Bài tập lớnBài tập luyện tập: Mô phỏng các chương trình sau NotePad, WordPadCalculatorAddress BookDuyệt fileDuyệt webPaintChương trình xem ảnhTừ điển Anh – ViệtGame MinesweeperQ&A220

File đính kèm:

  • pptxbai_giang_lap_trinh_windows_chuong_3_lap_trinh_c_tren_window.pptx