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


C# Form.Close方法代码示例

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


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

示例1: ShowDialog

 public static string ShowDialog(string baseSite,string text, string caption)
 {
     Form prompt = new Form();
     string resultURL="";
     prompt.Width = 600;
     prompt.Height = 420;
     prompt.Text = caption;
     
     Label textLabel = new Label() { Left = 10, Top=10, Width=580, Text=text };
     ListBox lbCounty = new ListBox() { Left = 10, Top=40, Width=250, Height = 340, DisplayMember = "Label" };
     Button confirmation = new Button() { Text = "Ok", Left=370, Width=100, Top=350 };
     Button cancel = new Button() { Text = "Cancel", Left=480, Width=100, Top=350 };
     
     confirmation.Click += (sender, e) => {
             if(lbCounty.SelectedItem!=null) {resultURL=lbCounty.SelectedItem.ToString();}
             prompt.Close();
         };
     lbCounty.DoubleClick += (sender, e) => { confirmation.PerformClick();};
     cancel.Click += (sender, e) => { resultURL = "";prompt.Close(); };
     
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(cancel);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(lbCounty);
     
     FillLbCounty(lbCounty,baseSite);
     
     prompt.ShowDialog();
     return resultURL;
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:30,代码来源:Update+Archived+from+Xylanthrop.cs

示例2: MainX

    public static void MainX()
    {
        var form = new Form();

        var label = new Label();
        label.Top = 10;
        label.Left = 10;
        label.Width = 200;
        label.Height = 20;
        label.Text = "Hello, Windows Forms!";
        form.Controls.Add(label);

        var button = new Button();
        button.Top = label.Bottom + 15;
        button.Left = label.Left;
        button.Width = label.Width;
        button.Height = 30;
        button.Text = "OK";
        button.Click += (sender, args) =>
            {
                form.Close();
            };
        form.Controls.Add(button);

        form.ClientSize = new System.Drawing.Size(button.Right + 10, button.Bottom + 10);
        Application.Run(form);
    }
开发者ID:KyMaP13,项目名称:Lecture,代码行数:27,代码来源:L1S01.cs

示例3: ShowDialog

    public static Point ShowDialog()
    {
        if (!_warningShown)
        {
          MessageBox.Show(@"for double use 1,04 format!");
          _warningShown = true;
        }

        Form prompt = new Form()
        {
          Width = 280,
          Height = 220,
          FormBorderStyle = FormBorderStyle.FixedDialog,
          Text = @"Enter 3D coordinates",
          StartPosition = FormStartPosition.CenterScreen
        };

        Label XtextLabel = new Label() {Left = 80, Top = 20, Text = "X"};
        TextBox XtextBox = new TextBox() {Left = 80, Top = 35, Width = 60};

        Label YtextLabel = new Label() {Left = 80, Top = 55, Text = "Y"};
        TextBox YtextBox = new TextBox() {Left = 80, Top = 70, Width = 60};

        Label ZtextLabel = new Label() {Left = 80, Top = 95, Text = "Z"};
        TextBox ZtextBox = new TextBox() {Left = 80, Top = 110, Width = 60};
        ZtextBox.Text = "0";
        ZtextBox.BackColor = Color.Gray;

        Button confirmation = new Button() {Text = "Ok", Left = 80, Width = 80, Top = 140, DialogResult = DialogResult.OK};
        confirmation.Click += (sender, e) => { prompt.Close(); };

        prompt.Controls.Add(XtextBox);
        prompt.Controls.Add(XtextLabel);

        prompt.Controls.Add(YtextBox);
        prompt.Controls.Add(YtextLabel);

        prompt.Controls.Add(ZtextBox);
        prompt.Controls.Add(ZtextLabel);

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

        if (prompt.ShowDialog() == DialogResult.OK)
        {

          double x = double.Parse(XtextBox.Text);
          double y = double.Parse(YtextBox.Text);
          double z = double.Parse(ZtextBox.Text);
          return new Point(x, y, z);
        }
        // недостижимый код
        return new Point();
    }
开发者ID:DiscoDancer,项目名称:Study,代码行数:54,代码来源:PointGetter3D.cs

示例4: ShowDialog

 public static string ShowDialog(string text, string caption)
 {
     var prompt = new Form();
         prompt.Width = 500;
         prompt.Height = 100;
         prompt.Text = caption;
         var textLabel = new Label() { Left = 50, Top = 20, Text = text };
         var textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
         var confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70 };
         confirmation.Click += (sender, e) => prompt.Close();
         prompt.Controls.Add(confirmation);
         prompt.Controls.Add(textLabel);
         prompt.Controls.Add(textBox);
         prompt.ShowDialog();
         return textBox.Text;
 }
开发者ID:socrat3z,项目名称:snippets,代码行数:16,代码来源:Prompt.cs

示例5: ShowDialog

    public static string ShowDialog(string caption, string text)
    {
        Form prompt = new Form();
        prompt.Width = 500;
        prompt.Height = 150;
        prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
        prompt.Text = caption;
        prompt.StartPosition = FormStartPosition.CenterScreen;
        Label textLabel = new Label() { Left = 50, Top=20, Text=text };
        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 += (sender, e) => { prompt.Close(); };
        prompt.Controls.Add(textBox);
        prompt.Controls.Add(confirmation);
        prompt.Controls.Add(textLabel);
        prompt.AcceptButton = confirmation;

        return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : "";
    }
开发者ID:lewisclement,项目名称:KBSGameGroep3,代码行数:19,代码来源:EditorGui.cs

示例6: Main

	static void Main ()
	{
		Form form = new Form ();
		form.ShowInTaskbar = false;

		TableLayoutPanel tableLayoutPanel = new TableLayoutPanel ();
		tableLayoutPanel.ColumnCount = 3;
		tableLayoutPanel.Dock = DockStyle.Fill;
		tableLayoutPanel.RowCount = 11;
		form.Controls.Add (tableLayoutPanel);

		Timer timer = new Timer ();
		timer.Interval = 100;
		timer.Tick += delegate (object sender, EventArgs e) {
			form.Close ();
		};

		form.Load += delegate (object sender, EventArgs e) {
			timer.Enabled = true;
		};
		form.ShowDialog ();
	}
开发者ID:mono,项目名称:gert,代码行数:22,代码来源:test.cs

示例7: ShowCheckDialog

            public static bool ShowCheckDialog(string text, string caption)
            {
                Form prompt = new Form();
                prompt.Width = 270;
                prompt.Height = 150;
                prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
                prompt.Text = caption;
                prompt.StartPosition = FormStartPosition.CenterScreen;
                Label textLabel = new Label() { Left = 10, Top = 20, Text = text };
                textLabel.AutoSize = true;
                Button confirmation = new Button() { Text = "Yes", Left = 80, Width = 60, Top = 70, DialogResult = DialogResult.OK };
                Button cancellation = new Button() { Text = "No", Left = 10, Width = 60, Top = 70, DialogResult = DialogResult.Cancel };
                confirmation.Click += (sender, e) => { prompt.Close(); };
                cancellation.Click += (sender, e) => { prompt.Close(); };
                prompt.Controls.Add(confirmation);
                prompt.Controls.Add(cancellation);
                prompt.Controls.Add(textLabel);
                prompt.AcceptButton = confirmation;

                prompt.AutoSize = true;
                prompt.AutoSizeMode = AutoSizeMode.GrowAndShrink;

                return prompt.ShowDialog() == DialogResult.OK;
            }
开发者ID:captaintino,项目名称:Bounced-Check-Manager,代码行数:24,代码来源:PayCheck.cs

示例8: CloseOpenedScreenshot

 private void CloseOpenedScreenshot(Form form)
 {
     form.Close();
 }
开发者ID:jpmarques,项目名称:mRemoteNC,代码行数:4,代码来源:UI.Window.ScreenshotManager.cs

示例9: ShowKeyboardInput

 public static void ShowKeyboardInput(string title, string description, string defaultText, Action<string> callback, string inputType = "")
 {
     Label DescriptionLabel = new Label()
     {
         AutoSize = true,
         Font = new Font("SimSun", 14.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
         Location = new Point(6, 9),
         Size = new Size(169, 19),
         Text = description
     };
     TextBox InputTextBox = new TextBox()
     {
         Font = new Font("SimSun", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
         Location = new Point(10, 46),
         Size = new Size(262, 26),
         Text = defaultText,
         SelectionStart = 0,
         SelectionLength = defaultText.Length
     };
     Button LeftButton = new Button()
     {
         Font = new Font("SimSun", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
         Location = new Point(10, 109),
         Size = new Size(128, 40),
         Text = "OK"
     };
     Button RightButton = new Button()
     {
         Font = new Font("SimSun", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
         Location = new Point(144, 109),
         Size = new Size(128, 40),
         Text = "Cancel"
     };
     Form InputForm = new Form()
     {
         AutoScaleDimensions = new SizeF(6F, 12F),
         AutoScaleMode = AutoScaleMode.Font,
         ClientSize = new Size(284, 161),
         Text = title,
         FormBorderStyle = FormBorderStyle.FixedDialog,
         MaximizeBox = false,
         MinimizeBox = false
     };
     InputForm.Controls.Add(DescriptionLabel);
     InputForm.Controls.Add(InputTextBox);
     InputForm.Controls.Add(LeftButton);
     InputForm.Controls.Add(RightButton);
     LeftButton.Click += (s, e) => { InputForm.Close(); callback(InputTextBox.Text); };
     RightButton.Click += (s, e) => { InputForm.Close(); callback(InputTextBox.Text); };
     InputForm.StartPosition = FormStartPosition.CenterParent;
     InputForm.ShowDialog();
 }
开发者ID:liwq-net,项目名称:UIFactory,代码行数:52,代码来源:Ime.cs

示例10: EditShowInfo


//.........这里部分代码省略.........
                    {
                        //throw new Exception("Error Parsing Date");
                        movieDate = movieYear + "-01-01";
                    }
                    else
                    {
                        string date = response.Substring(startindex, endindex - startindex);
                        string[] dateParts = date.Split(' ');
                        string month = "January";
                        string day = "01";
                        if (dateParts.Length == 2)
                        {
                            // Only Year
                            movieDate = movieYear;
                        }
                        else if (dateParts.Length == 3)
                        {
                            // Month and Year
                            month = dateParts[0].Trim();
                        }
                        else if (dateParts.Length == 4)
                        {
                            // Day Month Year
                            // Adjust length of day
                            if (dateParts[0].Trim().Length == 1)
                                day = "0" + dateParts[0].Trim();
                            month = dateParts[1].Trim();
                        }
                        else
                        {
                            throw new Exception("Error Forming Date");
                        }
                        movieDate = movieYear;
                        // Lookup Month
                        if (month.Equals("January"))
                            movieDate = movieDate + "-01-" + day;
                        else if (month.Equals("February"))
                            movieDate = movieDate + "-02-" + day;
                        else if (month.Equals("March"))
                            movieDate = movieDate + "-03-" + day;
                        else if (month.Equals("April"))
                            movieDate = movieDate + "-04-" + day;
                        else if (month.Equals("May"))
                            movieDate = movieDate + "-05-" + day;
                        else if (month.Equals("June"))
                            movieDate = movieDate + "-06-" + day;
                        else if (month.Equals("July"))
                            movieDate = movieDate + "-07-" + day;
                        else if (month.Equals("August"))
                            movieDate = movieDate + "-08-" + day;
                        else if (month.Equals("September"))
                            movieDate = movieDate + "-09-" + day;
                        else if (month.Equals("October"))
                            movieDate = movieDate + "-10-" + day;
                        else if (month.Equals("November"))
                            movieDate = movieDate + "-11-" + day;
                        else if (month.Equals("December"))
                            movieDate = movieDate + "-12-" + day;
                        else
                            throw new Exception("Error Forming Date");
                    }

                    // Set title as Movies for now.  This needs to be fixed so DisplayTitle gets set
                    // to "Movies" and Title get set to the movie name.
                    row["Title"] = "Movies";

                    // Set Episode Name as the movie
                    if (movieTitle.IndexOf("The") == 0)
                        movieTitle = movieTitle.Substring(4).Trim() + ", The";
                    if (movieTitle.IndexOf("A ") == 0)
                        movieTitle = movieTitle.Substring(2).Trim() + ", A";
                    if (movieTitle.IndexOf("An ") == 0)
                        movieTitle = movieTitle.Substring(3).Trim() + ", An";
                    row["EpisodeTitle"] = movieTitle;

                    // Set the Description
                    row["EpisodeDescription"] = moviePlot;

                    // Set the Genre
                    row["Genre"] = movieGenre;

                    // Set the Actors
                    row["Actors"] = movieActors;

                    // Set the Date
                    //string firstAired = "2099-01-01";
                    row["ActualStart"] = movieDate;
                    row["OriginalAirDate"] = movieDate.Replace("-", "");
                    row["MovieYear"] = movieYear;

                    updatedRowCount++;
                    count++;
                    Thread.Sleep(500);
                    progressForm.Update();
                }

                progressForm.Close();

                return (updatedRowCount > 0);
            }
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:101,代码来源:PluginMovieTagger.cs

示例11: EditShowInfo


//.........这里部分代码省略.........
                    progressLabel.Text = "Tagging " + count + "/" + table.Rows.Count + ": " + row["Name"].ToString();

                    if (DEBUG)
                    {
                        MessageBox.Show("Title: " + tagger.seriesName);
                        MessageBox.Show("Season: " + tagger.seasonNumber);
                        MessageBox.Show("Episode: " + tagger.episodeNumber);
                    }

                    // Check array first
                    int indexOfShowInArray = seriesNameList.IndexOf(tagger.seriesName);
                    if (indexOfShowInArray != -1)
                    {
                        if (DEBUG)
                            MessageBox.Show(tagger.seriesName + " exists in memory");
                        formalName = formalNameList[indexOfShowInArray];
                        seriesID = seriesIDList[indexOfShowInArray];
                    }
                    else
                    {
                        // Search theTVDB.com API for the series ID
                        URLString = "http://www.thetvdb.com/api/GetSeries.php?seriesname=" + tagger.seriesName + "&language=en";
                        reader = new XmlTextReader(URLString);
                        doc = new XmlDocument();
                        try
                        {
                            doc.Load(reader);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Bad URL: " + URLString + "\nSkipping.", row["Name"].ToString());
                            continue;
                        }
                        reader.Close();

                        // Get the series name and the index in the XML if there are multiple
                        XmlNodeList seriesNamesList = doc.GetElementsByTagName("SeriesName");
                        int seriesCount = seriesNamesList.Count;
                        int seriesIndex = 0;
                        // Check if any items were found
                        if (seriesCount == 0)
                        {
                            formalName = "";
                            // Nothing found
                            // Ask user if they want to manually search for show name or skip
                            DialogResult retval = MessageBox.Show("Nothing found.  Search for show manually?", row["Name"].ToString(), MessageBoxButtons.YesNo);
                            if (retval == DialogResult.Yes)
                            {
                                Boolean searchError = false;
                                Boolean tryAgain = true;
                                // While the user wants to try, keep searching
                                while (tryAgain)
                                {
                                    // Get the new series name and save
                                    string newSeriesName = Interaction.InputBox("Enter Series Name", row["Name"].ToString(), null, 0, 0);

                                    // Search theTVDB.com API for the series ID
                                    URLString = "http://www.thetvdb.com/api/GetSeries.php?seriesname=" + newSeriesName + "&language=en";
                                    reader = new XmlTextReader(URLString);
                                    doc = new XmlDocument();
                                    try
                                    {
                                        doc.Load(reader);
                                    }
                                    catch (Exception e)
                                    {
开发者ID:tmar89,项目名称:tmar89snapstreamdev,代码行数:67,代码来源:PluginTagFromTheTVDB.cs

示例12: button1_Click

	private void button1_Click (object sender, EventArgs e)
	{
		Form testForm = new Form ();
		var btn = new Button ();
		btn.Click += delegate { testForm.Close (); };
		testForm.Controls.Add (btn);
		testForm.ShowDialog ();
		//MessageBox.Show ("I was clicked");
		
	}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:10,代码来源:TestWinform.cs

示例13: closeForm

 public void closeForm(Form close_me)
 {
     if(close_me.InvokeRequired) {
             close_me.BeginInvoke(new closeFormDelegate(closeForm), new Object[] {close_me});
         } else {
             lock(close_me) {
                 close_me.Close();
             }
         }
 }
开发者ID:MissioDei,项目名称:MDSFM,代码行数:10,代码来源:invokes.cs

示例14: Test1

        public void Test1()
        {
            using (var tempFile = new TempFile())
            {
                {
                    var form = new Form();
                    var dataGridView1 = new DataGridView();
                    dataGridView1.Name = "dataGridView1";
                    dataGridView1.DataSource = new List<string>();
                    var dataGridView2 = new DataGridView();
                    dataGridView2.Name = "dataGridView2";
                    dataGridView2.DataSource = new List<string>();
                    form.Controls.Add(dataGridView1);
                    form.Controls.Add(dataGridView2);

                    new FormSettingsManager(form, tempFile.Value);
                    form.Load += (sender, e) =>
                    {
                        form.Location = new Point(33, 44);
                        form.Size = new Size(300, 222);
                        dataGridView1.Columns[0].Width = 222;
                        dataGridView2.Columns[0].Width = 333;
                        form.Close();
                    };
                    form.ShowDialog();
                    Assert.AreEqual(new Point(33, 44), form.Location);
                    Assert.AreEqual(new Size(300, 222), form.Size);
                }
            //				TestUtility.Show(File.ReadAllText(tempFile.Value));
                {
                    var form = new Form();
                    var dataGridView1 = new DataGridView();
                    dataGridView1.Name = "dataGridView1";
                    dataGridView1.DataSource = new List<string>();
                    var dataGridView2 = new DataGridView();
                    dataGridView2.Name = "dataGridView2";
                    dataGridView2.DataSource = new List<string>();
                    form.Controls.Add(dataGridView1);
                    form.Controls.Add(dataGridView2);

                    new FormSettingsManager(form, tempFile.Value);
                    form.Load += (sender, e) =>
                    {
                        form.Close();
                    };
                    form.ShowDialog();
                    Assert.AreEqual(new Point(33, 44), form.Location);
                    Assert.AreEqual(new Size(300, 222), form.Size);
                    Assert.AreEqual(222, dataGridView1.Columns[0].Width);
                    Assert.AreEqual(333, dataGridView2.Columns[0].Width);
                }
            }
        }
开发者ID:kaijin-games,项目名称:larning-english-game,代码行数:53,代码来源:FormSettingsManager.cs

示例15: ShowDialog

            public static string ShowDialog(string text, String defaultValue, string caption)
            {
                Form prompt = new Form()
                {
                    Width = 500,
                    Height = 200,
                    FormBorderStyle = FormBorderStyle.FixedDialog,
                    Text = caption,
                    StartPosition = FormStartPosition.CenterScreen
                };
                Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = text };
                TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
                textBox.Text = defaultValue;
                Button confirmation = new Button() { Text = "Ok", Left = 245, Width = 100, Top = 70, DialogResult = DialogResult.OK };
                Button cancel = new Button() { Text = "Cancel", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.Cancel };
                confirmation.Click += (sender, e) => { prompt.Close(); };
                cancel.Click += (sender, e) => { prompt.Close(); };
                prompt.Controls.Add(textBox);
                prompt.Controls.Add(confirmation);
                prompt.Controls.Add(cancel);
                prompt.Controls.Add(textLabel);
                prompt.AcceptButton = confirmation;

                return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : null;
            }
开发者ID:iainross,项目名称:EDDiscovery,代码行数:25,代码来源:TripPanelPopOut.cs


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