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: }
  • 相关阅读:
    SAP OPEN UI5 Step 8: Translatable Texts
    SAP OPEN UI5 Step7 JSON Model
    SAP OPEN UI5 Step6 Modules
    SAP OPEN UI5 Step5 Controllers
    SAP OPEN UI5 Step4 Xml View
    SAP OPEN UI5 Step3 Controls
    SAP OPEN UI5 Step2 Bootstrap
    SAP OPEN UI5 Step1 环境安装和hello world
    2021php最新composer的使用攻略
    Php使用gzdeflate和ZLIB_ENCODING_DEFLATE结果gzinflate报data error
  • 原文地址:https://www.cnblogs.com/hanzhaoxin/p/2845287.html
Copyright © 2011-2022 走看看