C#学习笔记——通用对话框
生活随笔
收集整理的這篇文章主要介紹了
C#学习笔记——通用对话框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Visual Studio提供的通用對話框控件有:ColorDialog、FolderBrowserDialog、FontDialog、OpenFileDialog、SaveFileDialog、PageSetupDialog、PrintDialog和PrintPreviewDialog。
在使用這些中的某個“通用對話框”控件時,可以向窗體添加該控件,并將其放在控件托盤上。可以保留這些控件的默認名字。如colorDialog1和fontDialog1,因為每種類型只有一個控件可以使用。
顯示windows通用對話框
dialogObject.ShowDialog();
示例代碼:
1: using System; 2: using System.Collections.Generic; 3: using System.ComponentModel; 4: using System.Data; 5: using System.Drawing; 6: using System.Linq; 7: using System.Text; 8: using System.Windows.Forms; 9:? 10: namespace CommonDialog 11: { 12: public partial class FormMain : Form 13: { 14: public FormMain() 15: { 16: InitializeComponent(); 17: } 18:? 19: private void btnColor_Click(object sender, EventArgs e) 20: { 21: colorDialog1.ShowDialog(); 22: txtShow.BackColor = colorDialog1.Color; 23: } 24:? 25: private void btnFont_Click(object sender, EventArgs e) 26: { 27: fontDialog1.ShowDialog(); 28: txtShow.Font = fontDialog1.Font; 29: } 30:? 31: private void button1_Click(object sender, EventArgs e) 32: { 33: folderBrowserDialog1.ShowDialog(); 34: txtShow.Text = folderBrowserDialog1.SelectedPath; 35: } 36: } 37: } 作者:韓兆新 出處:http://hanzhaoxin.cnblogs.com/ 本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。 分類:?[01]C#語言基礎 標簽:?C#學習筆記本文轉自韓兆新博客博客園博客,原文鏈接:http://www.cnblogs.com/hanzhaoxin/archive/2013/01/05/2845287.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的C#学习笔记——通用对话框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringMvc项目中使用Google
- 下一篇: c# char unsigned_dll