0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C# OpenFileDialogのFilterプロパティの書き方

Last updated at Posted at 2023-12-08
  1. 指定値に縦棒"|"が必要です。縦棒がなければ、ダイアログが開けない。
  2. 複数のパターンを指定するときも縦棒が必要です。

例:
"|パターン1"
"パターン1の説明|パターン1"
"パターン1の説明|パターン1|パターン2の説明|パターン2|パターン3の説明|パターン3"

1. "|パターン1"

private void Btn_Click(object sender, EventArgs e)
{
    using(OpenFileDialog op = new OpenFileDialog())
    {
        op.Title ="Open file";
        op.Filter = "|*.csv";
    }
}

image.png

2. "パターン1の説明|パターン1"

private void Btn_Click(object sender, EventArgs e)
{
    using(OpenFileDialog op = new OpenFileDialog())
    {
        op.Title ="Open file";
        op.Filter = "csvファイル|*.csv";
    }
}

image.png

3. "パターン1の説明|パターン1|パターン2の説明|パターン2|パターン3の説明|パターン3"

private void Btn_Click(object sender, EventArgs e)
{
    using(OpenFileDialog op = new OpenFileDialog())
    {
        op.Title ="Open file";
        op.Filter = "csvファイル|*.csv|txtファイル|*.txt|xlsxファイル|*.xlsx";
    }
}

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?