本文整理汇总了C#中System.Windows.Forms.Form.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# Form.ShowDialog方法的具体用法?C# Form.ShowDialog怎么用?C# Form.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowForm
public void ShowForm(Form form)
{
var activeForm = FormHelper.GetActiveForm();
if (activeForm != null)
{
activeForm.BeginInvoke(new Action(() => form.ShowDialog(activeForm)));
}
else
{
form.ShowDialog();
}
}
示例2: ShowDialog
public static DialogResult ShowDialog(Form parent, Form dialog)
{
//Enabled = false;
Form shadow = new Form();
shadow.MinimizeBox = false;
shadow.MaximizeBox = false;
shadow.ControlBox = false;
shadow.Text = "";
shadow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
//shadow.Size = Size;
shadow.BackColor = Color.Black;
shadow.Opacity = 0.3;
shadow.ShowInTaskbar = false;
shadow.WindowState = FormWindowState.Maximized;
shadow.Show();
//shadow.Location = Location;
shadow.Enabled = false;
var mask = new frmOpacity(parent, dialog);
dialog.StartPosition = FormStartPosition.CenterParent;
//mask.Show();
var result = dialog.ShowDialog(mask);
mask.Close();
shadow.Close();
return result;
}
示例3: apieToolStripMenuItem_Click
// PVZ kitom skiltim
private void apieToolStripMenuItem_Click(object sender, EventArgs e)
{
using (Form form = new Form())
{
form.Text = apieToolStripMenuItem.Text;
form.ClientSize = new System.Drawing.Size(1000, 500);
form.MinimumSize = new System.Drawing.Size(1000, 500);
RichTextBox about = new RichTextBox();
about.Dock = DockStyle.Fill;
about.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F);
about.Location = new System.Drawing.Point(4, 4);
about.ReadOnly = true;
about.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
if (apieToolStripMenuItem.Text == "Apie")
{
about.Text = Alfredas.Properties.Resources.AboutLT;
}
else if (apieToolStripMenuItem.Text == "About")
{
about.Text = Alfredas.Properties.Resources.AboutEN;
}
else if (apieToolStripMenuItem.Text == "Описание")
{
about.Text = Alfredas.Properties.Resources.AboutRU;
}
form.Controls.Add(about);
form.ShowDialog();
}
}
示例4: FileNew_menuitem_Click
private void FileNew_menuitem_Click(object sender, EventArgs e)
{
string newFileName = "";
Form form = new Form();
form.Width = 500;
form.Height = 150;
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.Text = "New Wizard Project File";
form.StartPosition = FormStartPosition.WindowsDefaultLocation;
Label textLabel = new Label() { Left = 50, Top = 20, Text = "Name:" };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK };
confirmation.Click += (formsender, forme) => { newFileName = textBox.Text; form.Close(); };
form.Controls.Add(textBox);
form.Controls.Add(confirmation);
form.Controls.Add(textLabel);
form.AcceptButton = confirmation;
DialogResult result = form.ShowDialog();
if(DialogResult.OK == result) // Create new file
{
_CreateNewMasterFile(newFileName);
}
form.Close();
}
示例5: viewLoadingScreenB_Click
private void viewLoadingScreenB_Click(object sender, EventArgs e)
{
Form loadinScreenForm = new Form();
loadinScreenForm.AutoScroll = true;
loadinScreenForm.StartPosition = FormStartPosition.CenterScreen;
loadinScreenForm.ShowIcon = false;
loadinScreenForm.ShowInTaskbar = false;
loadinScreenForm.MinimizeBox = false;
loadinScreenForm.MaximizeBox = false;
loadinScreenForm.FormBorderStyle = FormBorderStyle.FixedDialog;
Bitmap topLeft = DHRC.GetTgaImage("LoadingScreenTL.tga");
Bitmap topRight = DHRC.GetTgaImage("LoadingScreenTR.tga");
Bitmap bottomLeft = DHRC.GetTgaImage("LoadingScreenBL.tga");
Bitmap bottomRight = DHRC.GetTgaImage("LoadingScreenBR.tga");
Bitmap bmp = new Bitmap(topLeft.Width + topRight.Width, topLeft.Height + bottomLeft.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bmp);
g.DrawImageUnscaled(topLeft, 0, 0);
g.DrawImageUnscaled(topRight, topLeft.Width, 0);
g.DrawImageUnscaled(bottomLeft, 0, topLeft.Height);
g.DrawImageUnscaled(bottomRight, topLeft.Width, topLeft.Height);
loadinScreenForm.BackgroundImage = bmp;
loadinScreenForm.BackgroundImageLayout = ImageLayout.None;
loadinScreenForm.ClientSize = bmp.Size;
loadinScreenForm.ShowDialog();
}
示例6: ShowDialog
public static void ShowDialog( string Header, string Message )
{
Form Dialog = new Form();
Dialog.Width = 400;
Dialog.Height = 120;
Dialog.Text = Header;
Dialog.FormBorderStyle = FormBorderStyle.FixedDialog;
Label LabelMessage = new Label()
{
//Left = 0,
//Top = 0,
Width = Dialog.Width,
Height = Dialog.Height / 2,
Text = Message,
TextAlign = ContentAlignment.MiddleCenter,
Font = new Font( SystemFonts.MessageBoxFont.FontFamily.Name, 12.0f, FontStyle.Bold, GraphicsUnit.Point )
};
LabelMessage.TextAlign = ContentAlignment.MiddleCenter;
Button ButtonOK = new Button() { Text = "OK", Left = Dialog.Width - 100, Width = 80, Top = Dialog.Height - 70 };
ButtonOK.Click += ( sender, e ) => { Dialog.Close(); };
Dialog.Controls.Add( ButtonOK );
Dialog.Controls.Add( LabelMessage );
Dialog.ShowDialog();
}
示例7: MainForm
public MainForm()
{
InitializeComponent();
frmObj = new login();
frmObj.ShowDialog();
LoadMenu();
}
示例8: Show
public static DialogResult Show(string text, string head)
{
form1.Dispose();
form1 = new Form();
InitializeComponent();
if (form1.ParentForm == null)
form1.StartPosition = FormStartPosition.CenterScreen;
label1.Location = new Point(12, label1.Location.Y);
btnNames = AsignButtons(buttons);
form1.Text = head;
label1.Text = text;
FormAutoHeigh();
CenterButtons(btnNames.Length);
MakeButtons(btnNames, selNoBtn);
AddSound(icon);
DialogResult rez = form1.ShowDialog();
form1.Dispose();
return rez;
}
示例9: Activated_Dialog
public void Activated_Dialog ()
{
if (TestHelper.RunningOnUnix)
Assert.Ignore ("#4 fails");
_form = new DelayedCloseForm ();
EventLogger logger = new EventLogger (_form);
_form.ShowInTaskbar = false;
Assert.AreEqual (0, logger.CountEvents ("Activated"), "#1");
_form.Activate ();
Assert.AreEqual (0, logger.CountEvents ("Activated"), "#2");
_form.ShowDialog ();
Assert.AreEqual (1, logger.CountEvents ("Activated"), "#3");
_form.ShowDialog ();
Assert.AreEqual (2, logger.CountEvents ("Activated"), "#4");
}
示例10: EnhancedListViewTest
public void EnhancedListViewTest()
{
// To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
using (var frm = new Form())
{
using (var lv = new EnhancedListView { Dock = DockStyle.Fill, View = View.Details })
{
for (int j = 0; j < 4; j++)
{
lv.Columns.Add(j.ToString());
}
for (int i = 0; i < 1000; i++)
{
var item = new ListViewItem(i.ToString());
for (int j = 0; j < 4; j++)
{
item.SubItems.Add(j.ToString());
}
lv.Items.Add(item);
}
frm.Controls.Add(lv);
frm.ShowDialog();
}
}
}
示例11: ToBitmapGrayScale
public void ToBitmapGrayScale()
{
Mat img = new Mat(FilePath.Lenna511, LoadMode.GrayScale); // width % 4 != 0
Bitmap bitmap = BitmapConverter2.ToBitmap(img);
// Bitmap bitmap = img.ToBitmap();
using (var form = new Form())
using (var pb = new PictureBox())
{
pb.Image = bitmap;
var size = new System.Drawing.Size(bitmap.Width, bitmap.Height);
pb.ClientSize = size;
form.ClientSize = size;
form.Controls.Add(pb);
form.KeyPreview = true;
form.KeyDown += (sender, args) =>
{
if (args.KeyCode.HasFlag(Keys.Enter))
((Form)sender).Close();
};
form.Text = "Grayscale Mat to Bitmap Test";
form.ShowDialog();
}
}
示例12: listView1_DoubleClick
private void listView1_DoubleClick(object sender, EventArgs e)
{
Form f = new Form();
ListView lv = new ListView();
lv.Columns.Add("Value", 500);
foreach (string item in listView1.SelectedItems[0].SubItems[1].Text.Split(';'))
{
lv.Items.Add(item);
}
lv.DoubleClick += (sender2, e2) =>
{
ListView lv2 = (ListView)sender2;
string path = lv2.SelectedItems[0].Text;
if (!System.IO.Directory.Exists(path))
{
return;
}
System.Diagnostics.Process.Start("explorer.exe", path);
};
lv.View = View.Details;
lv.Dock = DockStyle.Fill;
f.Controls.Add(lv);
f.Text = listView1.SelectedItems[0].Text;
f.ShowDialog();
}
示例13: CreateForm
public static void CreateForm(string msg)
{
Form frm = new Form();
frm.MaximizeBox = false;
frm.MinimizeBox = false;
frm.Width = 800;
frm.Text = "Exception";
frm.ShowIcon = false;
frm.StartPosition = FormStartPosition.CenterScreen;
frm.FormBorderStyle = FormBorderStyle.Sizable;
TextBox edt = new TextBox();
edt.Multiline = true;
edt.Dock = DockStyle.Fill;
edt.ReadOnly = true;
edt.Cursor = Cursors.Default;
//edt.ScrollBars = ScrollBars.Horizontal;
//edt.WordWrap = false;
edt.Text = msg;
edt.SelectionStart =0;
//edt.SelectionStart = edt.Lines[0].Length + 5;
//edt.SelectionLength = edt.Lines[1].Length - 4;
frm.Controls.Add(edt);
frm.ShowDialog();
}
示例14: CreateForm
static void CreateForm()
{
Form form = new Form();
DataGridView grid = new DataGridView();
form.Controls.Add(grid);
grid.Dock = DockStyle.Fill;
// Create an instance of the PowerShell class.
// This takes care of all building all of the other
// data structures needed...
PowerShell powershell = PowerShell.Create().AddCommand("get-process").AddCommand("sort-object").AddArgument("ID");
if (Runspace.DefaultRunspace == null)
{
Runspace.DefaultRunspace = powershell.Runspace;
}
Collection<PSObject> results = powershell.Invoke();
// The generic collection needs to be re-wrapped in an ArrayList
// for data-binding to work...
ArrayList objects = new ArrayList();
objects.AddRange(results);
// The DataGridView will use the PSObjectTypeDescriptor type
// to retrieve the properties.
grid.DataSource = objects;
form.ShowDialog();
}
示例15: ShowDialog
public static string ShowDialog(string text, string caption, string value, bool isPassword)
{
Form prompt = new Form();
prompt.Width = 264;
prompt.Height = 140;
prompt.Text = caption;
Label textLabel = new Label() { Left = 12, Top = 22, Text = text, Width = 210 };
TextBox textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230 };
if (isPassword)
{
textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230, PasswordChar = '*' };
}
else
{
textBox = new TextBox() { Text = value, Left = 12, Top = 52, Width = 230 };
}
textBox.Focus();
textBox.KeyDown += (sender, e) =>
{
if (e.KeyValue != 13)
return;
prompt.Close();
};
Button confirmation = new Button() { Text = "Ok", Left = 142, Width = 100, Top = 78 };
confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.Controls.Add(textBox);
prompt.StartPosition = FormStartPosition.CenterParent;
prompt.ShowDialog();
return textBox.Text;
}