OpenFileDialog

Скрыть

Показать

Копировать
  Form1.cs  
  • 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 _0059 {
  •  public partial class Form1 : Form {
  •   public Form1() {
  •    InitializeComponent();
  •   }
  •   private void button1_Click(object sender, EventArgs e) {
  •    openFileDialog1.Filter = "Images (*.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png) | *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.png";
  •     if(openFileDialog1.ShowDialog() == DialogResult.OK) {
  •      Bitmap myImage = new Bitmap(openFileDialog1.FileName);
  •      pictureBox1.Image = (Image)myImage;
  •      textBox1.Visible = true;
  •      textBox1.Text = openFileDialog1.FileName;
  •     }
  •   }
  •  }
  • }