当前位置: 首页>>代码示例>>C#>>正文


C# Form.Close方法代码示例

本文整理汇总了C#中System.Windows.Forms.Form.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Form.Close方法的具体用法?C# Form.Close怎么用?C# Form.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Form的用法示例。


在下文中一共展示了Form.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectRow_ShouldMaintain_ActivePosition

		public void SelectRow_ShouldMaintain_ActivePosition()
		{
			// set up special conditions
			var grid = new Grid();
			grid.Redim(1, 1);
			grid[0, 0] = new Cell();
			
			var form = new Form();
			form.Controls.Add(grid);
			form.Show();

			grid.SelectionMode = GridSelectionMode.Row;
			grid.Selection.EnableMultiSelection = false;
			
			
			// just assert that we have correct conditions for test, 
			// active position should not be empty
			grid.Selection.Focus(new Position(0, 0), true);
			Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition);
			
			// this method causes first row to be selected. Should not fail 
			// it failed once in RowSelection.SelectRow method
			// As call to ResetSelection asked to maintain focus, a stack overflow was raised
			grid.Selection.SelectRow(0, true);
			Assert.AreEqual(new Position(0, 0), grid.Selection.ActivePosition);
			
			// destroy
			form.Close();
			form.Dispose();
		}
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:30,代码来源:TestRowSelection.cs

示例2: ShowDialog

        public static string ShowDialog(string text, string caption, string initalValue="")
        {
            Label textLabel = new Label() { Left = 30, Top = 5, Width = 200, Text = text };
            TextBox textBox = new TextBox() { Left = 30, Top = 35, Width = 200, Text = initalValue };
            Button confirmation = new Button() { Text = "Ok", Left = 105, Width = 70, Top = 80 };
            Button cancel = new Button() { Text = "Cancel", Left = 180, Width = 70, Top = 80 };
            Form prompt = new Form {Text = caption, ShowIcon = false, AcceptButton = confirmation, CancelButton = cancel,
                AutoSize = true, MaximizeBox = false, MinimizeBox = false, AutoSizeMode = AutoSizeMode.GrowAndShrink,
                SizeGripStyle = SizeGripStyle.Hide, ShowInTaskbar = false, StartPosition = FormStartPosition.CenterParent};

            confirmation.Click += (sender, e) =>
                {
                    prompt.DialogResult = DialogResult.OK;
                    prompt.Close();
                };
            cancel.Click += (sender, e) =>
                {
                    textBox.Clear();
                    prompt.DialogResult = DialogResult.Cancel;
                    prompt.Close();
                };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ActiveControl = textBox;

            var result = prompt.ShowDialog();

            return result == DialogResult.OK ? textBox.Text.Trim() : null;
        }
开发者ID:JohnChantzis,项目名称:bark_GUI,代码行数:32,代码来源:InputBox.cs

示例3: ShowDialog

        public static string ShowDialog(string text, string currentValue, string promptName)
        {
            System.Windows.Forms.Form prompt = new System.Windows.Forms.Form();
            prompt.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
            prompt.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            prompt.ClientSize = new System.Drawing.Size(284, 67);
            prompt.MaximizeBox = false;
            prompt.MinimizeBox = false;
            prompt.Text = promptName;
            prompt.FormBorderStyle = FormBorderStyle.FixedSingle;
            prompt.Name = "dlgPrompt";
            prompt.Font = new Font("Calibri", 9, FontStyle.Regular);
            prompt.StartPosition = FormStartPosition.CenterParent;

            System.Windows.Forms.Label textLabel = new System.Windows.Forms.Label() { Location = new System.Drawing.Point(12, 5), Size = new System.Drawing.Size(185, 23), Text = text, TextAlign = System.Drawing.ContentAlignment.MiddleLeft };
            System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox() { Location = new System.Drawing.Point(12, 34), Size = new System.Drawing.Size(185, 23), Text = currentValue };
            System.Windows.Forms.Button confirmation = new System.Windows.Forms.Button() { Location = new System.Drawing.Point(217, 5), Size = new System.Drawing.Size(55, 23), Text = "OK" };
            System.Windows.Forms.Button cancel = new System.Windows.Forms.Button() { Location = new System.Drawing.Point(217, 34), Size = new System.Drawing.Size(55, 23), Text = "Cancel" };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            cancel.Click += (sender, e) => { textBox.Text = string.Empty;  prompt.Close(); };

            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);
            prompt.ShowDialog();

            return textBox.Text;
        }
开发者ID:aquashift,项目名称:hattrick-manager-oauth,代码行数:30,代码来源:TextPrompt.cs

示例4: ShowDialog

 public static string ShowDialog(string text, string caption, string defaultValue = "")
 {
     Form prompt = new Form();
     prompt.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
     prompt.Width = 250;
     prompt.Height = 150;
     prompt.Text = caption;
     Label textLabel = new Label() { Left = 10, Top = 10, Text = text, AutoSize = true };
     TextBox textBox = new TextBox() { Left = 10, Top = 35, Width = 210 };
     textBox.Text = defaultValue;
     Button confirmation = new Button() { Text = "OK", Left = 10, Width = 60, Top = 70 };
     Button cancel = new Button() { Text = "Cancel", Left = 90, Width = 60, Top = 70 };
     confirmation.Click += (sender, e) => { prompt.DialogResult = DialogResult.OK; prompt.Close(); };
     cancel.Click += (sender, e) => { prompt.DialogResult = DialogResult.Cancel; prompt.Close(); };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(cancel);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(textBox);
     prompt.AcceptButton = confirmation;
     prompt.CancelButton = cancel;
     DialogResult Result = prompt.ShowDialog();
     if (Result == DialogResult.Cancel)
         return null;
     if (Result == DialogResult.OK)
         return textBox.Text;
     else
         return null;
 }
开发者ID:r1cebank,项目名称:AmiMat,代码行数:28,代码来源:InputPrompt.cs

示例5: button4_Click

        private void button4_Click(object sender, EventArgs e)
        {
            Form prompt = new Form();
            prompt.Width = 500;
            prompt.Height = 150;
            prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
            prompt.Text = "Cancel an order";
            prompt.StartPosition = FormStartPosition.CenterScreen;
            Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = "Enter tracking number to cancel:" };
            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
            Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 };
            Button cancel = new Button() { Text = "Cancel", Left = 250, Width = 100, Top = 70 };
            confirmation.DialogResult = DialogResult.OK;
            confirmation.Click += (sndr, evnt) => { prompt.Close(); };
            cancel.Click += (sndr, evnt) => { prompt.Close(); };
            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(cancel);
            prompt.Controls.Add(textLabel);
            prompt.CancelButton = cancel;
            prompt.AcceptButton = confirmation;
            DialogResult result = prompt.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK || textBox.Text.Length == 0)
                return;

            DeleteShipmentRequest req = new DeleteShipmentRequest();
            req.WebAuthenticationDetail = plugin.auth;
            req.ClientDetail = plugin.clientDetail;
            req.Version = new VersionId();

            req.TransactionDetail = new TransactionDetail();
            req.TransactionDetail.CustomerTransactionId = textBox.Text;

            req.TrackingId = new TrackingId();
            req.TrackingId.TrackingNumber = textBox.Text;
            req.TrackingId.TrackingIdType = TrackingIdType.EXPRESS;
            req.TrackingId.TrackingIdTypeSpecified = true;

            req.DeletionControl = DeletionControlType.DELETE_ALL_PACKAGES;

            var reply = plugin.svc.deleteShipment(req);

            if (reply.HighestSeverity == NotificationSeverityType.SUCCESS) {
                MessageBox.Show("Success");
            } else {
                var output = "";

                for (int i = 0; i < reply.Notifications.Length; i++)
                {
                    Notification notification = reply.Notifications[i];
                    output += string.Format("Notification no. {0}\n", i);
                    output += string.Format(" Severity: {0}\n", notification.Severity);
                    output += string.Format(" Code: {0}\n", notification.Code);
                    output += string.Format(" Message: {0}\n", notification.Message);
                    output += string.Format(" Source: {0}\n", notification.Source);
                }
                MessageBox.Show("Failed!\n\n" + output);
            }
        }
开发者ID:AudriusButkevicius,项目名称:probable-bassoon,代码行数:60,代码来源:Settings.cs

示例6: ShowTextDialog

        public static string ShowTextDialog(string caption)
        {
            var prompt = new Form()
            {
                FormBorderStyle = FormBorderStyle.FixedDialog,
                MinimizeBox = false,
                MaximizeBox = false,
                Width = 200,
                Height = 110,
                Text = caption,
                StartPosition = FormStartPosition.CenterScreen,
            };

            var cancel = new Button();
            cancel.Click += (sender, e) => prompt.Close();
            prompt.CancelButton = cancel;

            var textBox = new TextBox() { Left = 20, Top = 20, Width = 160, Height = 80, Text = "" };
            var confirmation = new Button() { Text = "Ok", Left = 50, Top = 50, Width = 100, DialogResult = DialogResult.OK };
            confirmation.Click += (sender, e) => { prompt.Close(); };

            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;

            textBox.Select(0, textBox.Text.Length);

            if (prompt.ShowDialog() == DialogResult.OK)
            {
                return textBox.Text;
            }
            return null;
        }
开发者ID:oswellchan,项目名称:PowerPointLabs,代码行数:33,代码来源:DrawingsLabDialogs.cs

示例7: 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;
        }
开发者ID:EricBlack,项目名称:web-automation,代码行数:34,代码来源:Prompt.cs

示例8: 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();
        }
开发者ID:Yogr,项目名称:Wizard,代码行数:27,代码来源:MainForm.cs

示例9: Show

        public static string Show(string message)
        {
            string answer = string.Empty;

            using (var ask = new Form())
            {
                var stack_styles = new Dictionary<object, object>();
                stack_styles.Add("background", "mistyrose");
                stack_styles.Add("heigth", "1.0");
                stack_styles.Add("width", "1.0");
                var stack = new Stack(stack_styles);
                var para = new Para();
                para.Text = message;
                stack.AddControl(para);

                var edit_box = new TextBox();
                stack.AddControl(edit_box);

                var flow_styles = new Dictionary<object, object>();
                flow_styles.Add("background", "gray");
                flow_styles.Add("width", "0.9");
                var flow = new Flow(flow_styles);
                flow.FlowDirection = FlowDirection.RightToLeft;

                var button_ok = new SteelToeBoots.Library.Elements.Button();
                button_ok.Text = "OK";
                button_ok.Click += (object o, EventArgs e) => {
                    answer = edit_box.Text;
                    ask.Close();
                };
                flow.AddControl(button_ok);

                var button_canel = new SteelToeBoots.Library.Elements.Button();
                button_canel.Text = "Cancel";
                button_canel.Click += (object o, EventArgs e) => {
                    answer = string.Empty;
                    ask.Close();
                };
                flow.AddControl(button_canel);

                stack.AddControl(flow);

                ask.Text = "Boots ask:";
                //ask.AddControl(stack);
                ask.Controls.Add(stack);

                ask.ShowDialog();
            }

            return answer;
        }
开发者ID:timothymoriarty,项目名称:boots,代码行数:51,代码来源:Ask.cs

示例10: 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;
        }
开发者ID:pcthanh,项目名称:POSEZ2U,代码行数:27,代码来源:frmOpacity.cs

示例11: ShowDialog

 public static string ShowDialog(string text, string caption, List<string> comboitems)
 {
     prompt = new Form();
     prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged);
     prompt.AutoSizeMode = AutoSizeMode.GrowOnly;
     prompt.Padding = new Padding(50);
     prompt.Text = caption;
     textLabel = new Label() { Text = text, AutoSize = true};
     textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
     textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
     comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)};
     comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
     comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
     confirmation = new Button() {Text = "OK" };
     confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
     confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
     confirmation.Click += (sender, e) => { prompt.Close(); };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(comboBox);
     prompt.AcceptButton = confirmation;
     prompt.AutoSize = true;
     prompt.Refresh();
     prompt.ShowDialog();
     return comboBox.SelectedItem.ToString();
 }
开发者ID:Merp,项目名称:SharpTune,代码行数:26,代码来源:SimpleCombo.cs

示例12: ShowDialog_Text_Combo

        public static void ShowDialog_Text_Combo(string caption, string text, string text2 , ref string defText1, List<string> comboItems, out string selectedItem)
        {
            Form prompt = new Form();
            prompt.Width = 280;
            prompt.Height = 180;
            prompt.Text = caption;
            Label textLabel = new Label() { Left = 16, Top = 10, Width = 240, Text = text };
            TextBox textBox = new TextBox() { Left = 16, Top = 35, Width = 240, TabIndex = 0, TabStop = true, Text = defText1 };
            //CheckBox ckbx = new CheckBox() { Left = 16, Top = 60, Width = 240, Text = boolStr };

            Label textLabel2 = new Label() { Left = 16, Top = 60, Width = 240, Text = text2 };
            ComboBox cbox = new ComboBox() { Left = 16, Top = 85, Width = 240, DataSource = comboItems, TabStop = true };

            Button confirmation = new Button() { Text = "OK", Left = 16, Width = 80, Top = 110, TabIndex = 1, TabStop = true };
            confirmation.Click += (sender, e) =>
            {
                prompt.Close();
            };
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(textBox);

            prompt.Controls.Add(textLabel2);
            prompt.Controls.Add(cbox);

            //prompt.Controls.Add(ckbx);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;
            prompt.StartPosition = FormStartPosition.CenterScreen;
            prompt.ShowDialog();
            defText1 = textBox.Text;
            selectedItem = (string)cbox.SelectedItem;
        }
开发者ID:Lowhuhn,项目名称:LaserControl,代码行数:32,代码来源:Prompts.cs

示例13: AddPoseCombination

 public void AddPoseCombination(Window window, PoseCombination poseCombination, bool isEdit, int editIndex, Form form)
 {
     if (isEdit && !window.IsExistPoseCombinationEdit(poseCombination, editIndex))
     {
         window.RemovePoseCombinationByIndex(editIndex);
         window.InsertPoseCombination(editIndex, poseCombination);
         form.Close();
     }
     else if (!isEdit && !window.IsExistPoseCombination(poseCombination))
     {
         window.AddPoseCombination(poseCombination);
         form.Close();
     }
     else
         MessageBox.Show("此手勢組合已選擇過!!!", "警告", MessageBoxButtons.OK);
 }
开发者ID:shana0440,项目名称:easy-control-myo-sharp,代码行数:16,代码来源:PoseCombinationSelectPModel.cs

示例14: FormClosing

 public void FormClosing(Form frmSource)
 {
     if (frmSource != null)
     {
         frmSource.Close();
     }
 }
开发者ID:Klutzdon,项目名称:SIOTS_HHZX,代码行数:7,代码来源:SystemToolBar.cs

示例15: TestTabMovement_DoesLoopCorrectly_ThroughSpannedRowCells

		public void TestTabMovement_DoesLoopCorrectly_ThroughSpannedRowCells()
		{
			using (var form = new Form())
			{
				
				Grid grid1 = new Grid();
				grid1.Redim(40,3);
				grid1.FixedColumns = 1;
				grid1.FixedRows = 1;

				Random rnd = new Random();
				for (int r = 0; r < grid1.RowsCount/2; r++)
				{
					for (int c = 0; c < grid1.ColumnsCount; c++)
					{
						grid1[r * 2, c] = new SourceGrid.Cells.Cell(r*c);
						grid1[r * 2, c].RowSpan = 2;
					}
				}
				
				form.Controls.Add(grid1);
				form.Show();
				
				Assert.AreEqual(true, grid1.Selection.Focus(new Position(0, 0), true));
				Assert.AreEqual(new Position(0, 0), grid1.Selection.ActivePosition);
				
				Assert.AreEqual(true, grid1.Selection.Focus(new Position(1, 0), true));
				Assert.AreEqual(new Position(1, 0), grid1.Selection.ActivePosition);
				
				form.Close();
			}
		}
开发者ID:wsrf2009,项目名称:KnxUiEditor,代码行数:32,代码来源:TestRangeMergerByRows.cs


注:本文中的System.Windows.Forms.Form.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。