1. Form Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | using System; using System.Drawing; using System.Windows.Forms; namespace WindowsFormsApp3 { public class Program : Form { CsListBox listBox; CsTextBox textBox; CsStatusBar statusBar; public Program() { Initialize(); } public static void Main(String[] args) { Application.Run(new Program()); } private void Initialize() { this.Name = "Window"; this.Text = "Window"; this.Size = new Size(640, 400); this.StartPosition = FormStartPosition.CenterScreen; makeToolBar(); makeMenuBar(); makeStatusBar(); makePanel(); this.Controls.Add(new CsButton("Hello", MyButtonClick)); } private void makeMenuBar() { CsMenuBar menu = new CsMenuBar(); menu.addMenu("File"); menu.addMenuItem("Exit", showExitPopup); menu.addMenu("Help"); menu.addMenuItem("About", showAboutPopup); this.Controls.Add(menu.get()); } private void makeToolBar() { CsToolBar tool = new CsToolBar(); tool.addToolItem("Exit", showExitPopup); this.Controls.Add(tool.get()); } private void makeStatusBar() { statusBar = new CsStatusBar(); statusBar.addPanel("Ready"); statusBar.setText(0, "Ready"); this.Controls.Add(statusBar.get()); } private void makePanel() { listBox = new CsListBox(showSelectedList); for (int i = 0; i < 10; i++) { listBox.addItem("Item" + i); } textBox = new CsTextBox(); textBox.addText("Test"); CsSplitContainer split = new CsSplitContainer(); split.addLeftPanel(listBox.get()); split.addRightPanel(textBox.get()); this.Controls.Add(split.get()); } private void MyButtonClick(object source, EventArgs e) { MessageBox.Show("My First WinForm Application"); } private void showExitPopup(object source, EventArgs e) { Application.Exit(); } private void showAboutPopup(object source, EventArgs e) { MessageBox.Show("Windows Form Demo V0.1"); } private void showSelectedList(object source, EventArgs e) { statusBar.setText(0, listBox.getSelectedText()); } } } |
댓글 없음:
댓글 쓰기