Button.DialogResult : Button « System.Windows.Forms « C# / C Sharp by API






Button.DialogResult

 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class SimplerDialog: Form
{
     public static void Main()
     {
          Application.Run(new SimplerDialog());
     }
     public SimplerDialog()
     {
          Text = "Simpler Dialog";
   
          Menu = new MainMenu();
          Menu.MenuItems.Add("&Dialog!", new EventHandler(MenuOnClick));
     }
     void MenuOnClick(object obj, EventArgs ea)
     {
          SimplerDialogBox dlg = new SimplerDialogBox();
          DialogResult     dr  = dlg.ShowDialog();
   
          Console.WriteLine(dr);
     }
}
class SimplerDialogBox: Form
{
     public SimplerDialogBox()
     {
          Text = "Simpler Dialog Box";
   
          FormBorderStyle = FormBorderStyle.FixedDialog;
          ControlBox      = false;
          MaximizeBox     = false;
          MinimizeBox     = false;
          ShowInTaskbar   = false;
   
          Button btn = new Button();
          btn.Parent   = this;
          btn.Text     = "OK";
          btn.Location = new Point(50, 50);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.OK;
   
          btn = new Button();
          btn.Parent   = this;
          btn.Text     = "Cancel";
          btn.Location = new Point(50, 100);
          btn.Size     = new Size (10 * Font.Height, 2 * Font.Height);
          btn.DialogResult = DialogResult.Cancel;
     }
}

   
  








Related examples in the same category

1.new Button()
2.Button.Anchor
3.Button.Click
4.Button.Dock
5.Button.FlatStyle
6.Button.Font
7.Button.Image
8.Button.Location
9.Button.MouseDown
10.Button.MouseEnter
11.Button.Parent
12.Button.PerformClick()
13.Button.Size
14.Button.Text
15.Button.TextAlign
16.Button.Top