zoukankan      html  css  js  c++  java
  • 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: }
  • 相关阅读:
    js 数据图表
    yii query builder
    mysql if
    这又是起点
    [cookie篇]从cookie-parser中间件说起
    How to find and fix Bash Shell-shock vulnerability CVE-2014-6271 in unix like system
    AngularJS打印问题
    笔记本上班时间自动静音下班自动打开
    SCP命令
    Installing Ruby 1.9.3 on Ubuntu 12.04 Precise Pengolin (without RVM)
  • 原文地址:https://www.cnblogs.com/hanzhaoxin/p/2845287.html
Copyright © 2011-2022 走看看