1 / 16

Multiple Document Interface Implementation Guide

Learn to set up MDI interface with default styles, menu strips, tool strips, and manage multiple document windows effectively using C# programming language.

bdeans
Download Presentation

Multiple Document Interface Implementation Guide

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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; }

More Related