Use of Dialog Box in C#
Now we are going to learn about dialog box in C#.
Introduction
In Windows Programming we have use dialog box. But we have insure that dialog box will not open automatically. It's working behalf a custom code. There is button when we clicked button then dialog box will open. Lets see how it works.
Example
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
}
Console.WriteLine(result);
}
}
}
Output