Presentation is loading. Please wait.

Presentation is loading. Please wait.

MDI介面建置 建國科技大學 資管系 饒瑞佶.

Similar presentations


Presentation on theme: "MDI介面建置 建國科技大學 資管系 饒瑞佶."— Presentation transcript:

1 MDI介面建置 建國科技大學 資管系 饒瑞佶

2 多重文件視窗 Multiple Document Interface

3 MDI父表單

4 預設MDI樣式 menustrip toolstrip 這裡面有些程式可以學 statusStrip

5 關閉所有表單 foreach (Form childForm in MdiChildren) { childForm.Close(); }

6 表單的排列 private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade); } private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileVertical); private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.TileHorizontal); private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) LayoutMdi(MdiLayout.ArrangeIcons);

7 開新視窗(未來開啟表單的方法) private int childFormNumber = 0;
Form childForm = new Form(); childForm.MdiParent = this; childForm.Text = "視窗 " + childFormNumber++; childForm.Show();

8 開啟/另存檔案 private void OpenFile(object sender, EventArgs e) {
OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); openFileDialog.Filter = "文字檔 (*.txt)|*.txt|所有檔案 (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) string FileName = openFileDialog.FileName; } private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); saveFileDialog.Filter = "文字檔 (*.txt)|*.txt|所有檔案 (*.*)|*.*"; if (saveFileDialog.ShowDialog(this) == DialogResult.OK) string FileName = saveFileDialog.FileName; }

9 修改MDI 刪除所有物件,重新加入MenuStrip下拉選單物件

10 在MDI中顯示表單 //先宣告表單物件(全域變數) private 表單 表單物件 = null;
if (表單物件 == null ||表單物件.IsDisposed) { //判斷要開啟的視窗是否已經存在 表單物件 = new 表單(); 表單物件.MdiParent = this; 表單物件.Show(); } else { 表單物件.Activate(); // 跳到最前面一個視窗

11 重新加入toolstrip 使用16 x 16大小的圖示(icon) 透過Items設定選項與圖示

12 加入與設定Button

13 選擇Image圖示

14 也可以直接在畫面上加入toolstrip上的物件
private void toolStripButton1_Click(object sender, EventArgs e) { MessageBox.Show(toolStripTextBox1.Text); }

15 重新加入statusStrip 竟然是toolStrip

16 試試toolStripProgressBar
private void MDIParent1_Load(object sender, EventArgs e) { toolStripProgressBar1.Minimum = 0; toolStripProgressBar1.Maximum = 100; } private void timer1_Tick(object sender, EventArgs e) toolStripProgressBar1.Value += 10; if(toolStripProgressBar1.Value == toolStripProgressBar1.Maximum) timer1.Enabled = false;


Download ppt "MDI介面建置 建國科技大學 資管系 饒瑞佶."

Similar presentations


Ads by Google