C#
実際にCustomOpenFileDialogを作ってみる。
出典: C#でOpenFileDialogが継承できない?それならフィールドに持っちゃえばいいんじゃね? — 実際にCustomOpenFileDialogを作ってみる。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CustomOpenFileDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
var cofd = new CustomOpenFileDialog();
if (cofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = cofd.FileName;
}
}
}
▸ この snippet は実行結果未収録
▸ 実行結果は未収録です
Source収録記事
この snippet は記事の「実際にCustomOpenFileDialogを作ってみる。」セクションに登場する。コードの前後の文脈・ハマりどころの解説は記事本文で。
同じ記事から
4 件using System; using System.IO; using System.Windows.Forms;未収録
実際にCustomOpenFileDialogを作ってみる。
#8467efcda984
public enum FilterType { HTML = 1, CSV未収録
これを応用すると下記のような感じにもできる。
#4150199d1ce1
public class CustomOpenFileDialog { private OpenFileDialog _ofd;未収録
これを応用すると下記のような感じにもできる。
#b19dc111a5eb
private void button1_Click(object sender, EventArgs e) { var cofd = new CustomOpenFileDialog(FilterType.CSV); if (cofd.ShowDialog() == DialogResult.OK)未収録
これを応用すると下記のような感じにもできる。
#3cbb7f609ff9
