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


C# Button.Dispose方法代码示例

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


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

示例1: RemoveFocus

 public static void RemoveFocus(Control ctrl)
 {
     Button btn = new Button();
     btn.Parent = ctrl;
     btn.Left = -9999;
     btn.Top = -9999;
     btn.Focus();
     btn.Dispose();
 }
开发者ID:450640526,项目名称:HtmExplorer,代码行数:9,代码来源:System.cs

示例2: GetName

        //===========================================================================
        //
        // Functions
        //
        //===========================================================================
        //
        // GetName(string text, string oldName)
        // Opens the get name form, allowing the user to input a name
        //
        private string GetName(string text, string oldName)
        {
            //Construct the form
            string name = null;
            Form nameForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false };
            nameForm.StartPosition = FormStartPosition.CenterParent;
            nameForm.Width = 200;
            nameForm.Height = 110;
            nameForm.Text = "NSS Keylogger";
            nameForm.Icon = Properties.Resources.nsskeylogger;
            nameForm.BackColor = Color.Black;

            Label lblName = new Label()
            {
                Width = 190,
                Height = 20,
                Location = new Point(5, 2),
                Text = text,
                ForeColor = Color.White
            };

            TextBox tbName = new TextBox()
            {
                Width = 185,
                Height = 20,
                Location = new Point(5, 23),
                Text = oldName
            };

            Button btnOK = new Button()
            {
                Width = 92,
                Height = 25,
                Location = new Point(5, 48),
                ImageAlign = ContentAlignment.MiddleCenter,
                TextAlign = ContentAlignment.MiddleCenter,
                Text = "OK",
                BackColor = SystemColors.ButtonFace,
                UseVisualStyleBackColor = true
            };
            btnOK.Click += (btnOKSender, btnOKe) =>
            {
                name = tbName.Text; //save the name
                nameForm.Close(); //close the form
            };

            Button btnCancel = new Button()
            {
                Width = 92,
                Height = 25,
                Location = new Point(98, 48),
                ImageAlign = ContentAlignment.MiddleCenter,
                TextAlign = ContentAlignment.MiddleCenter,
                Text = "Cancel",
                BackColor = SystemColors.ButtonFace,
                UseVisualStyleBackColor = true
            };
            btnCancel.Click += (btnCancelSender, btnCancele) =>
            {
                nameForm.Close(); //close the form without saving
            };

            //Build the form and show it
            nameForm.AcceptButton = btnOK;
            nameForm.CancelButton = btnCancel;
            nameForm.Controls.Add(lblName);
            nameForm.Controls.Add(tbName);
            nameForm.Controls.Add(btnOK);
            nameForm.Controls.Add(btnCancel);
            nameForm.ShowDialog();

            //Dispose the form's elements
            btnCancel.Dispose();
            btnOK.Dispose();
            tbName.Dispose();
            lblName.Dispose();
            nameForm.Dispose();

            return name;
        }
开发者ID:Coolcord,项目名称:NSS_Keylogger,代码行数:89,代码来源:ProfileManager.cs

示例3: RemoveForm

        public static void RemoveForm(Control source, Form form)
        {
            ContainerControl container = source.FindForm() as ContainerControl;

            if (container == null)
                container = source as ContainerControl;

            Button tempButton = new Button();
            tempButton.Visible = false;

            // Add this temporary button to the parent form
            container.Controls.Add(tempButton);

            // Must ensure that temp button is the active one
            container.ActiveControl = tempButton;

            // Remove Form parent
            form.Parent = null;

            // Remove the temporary button
            tempButton.Dispose();
            container.Controls.Remove(tempButton);
        }
开发者ID:krishnais,项目名称:ProfileSharp,代码行数:23,代码来源:ControlHelper.cs

示例4: btnAbout_Click

        private void btnAbout_Click(object sender, EventArgs e)
        {
            Form aboutForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false };
            aboutForm.StartPosition = FormStartPosition.CenterParent;
            aboutForm.Width = 400;
            aboutForm.Height = 200;
            aboutForm.Text = "About Clicktastic";
            aboutForm.Icon = Properties.Resources.clicktastic;
            aboutForm.BackColor = Color.Black;

            //Get the version number
            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            Label aboutText = new Label()
            {
                Width = 400,
                Height = 130,
                Location = new Point(0, 0),
                ImageAlign = ContentAlignment.MiddleCenter,
                TextAlign = ContentAlignment.MiddleCenter,
                Text = "Clicktastic v" + fileVersionInfo.ProductMajorPart + "." + fileVersionInfo.ProductMinorPart + "." + fileVersionInfo.ProductBuildPart + "\n\n" +
                    "Mass Click Mouse Buttons or\n" + "Mass Press Keyboard Keys\n\n" +
                    "Programmed and Designed by Coolcord"
            };
            Font aboutFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            aboutText.Font = aboutFont;
            aboutText.ForeColor = Color.White;
            Button btnOk = new Button() { Width = 100, Height = 30, Text = "OK", Location = new Point(150, 130), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter };
            btnOk.Click += (btnSender, btnE) => aboutForm.Close(); //click ok to close
            btnOk.BackColor = SystemColors.ButtonFace;
            btnOk.UseVisualStyleBackColor = true;
            aboutForm.AcceptButton = btnOk;
            aboutForm.Controls.Add(aboutText);
            aboutForm.Controls.Add(btnOk);

            //Easter Egg =D
            aboutForm.KeyPreview = true;
            CheatCode cheatCode = new CheatCode();
            aboutForm.KeyDown += new KeyEventHandler(cheatCode.GetCheatCode);

            //All done with the about form
            aboutForm.ShowDialog();
            aboutForm.Dispose();
            btnOk.Dispose();
            aboutText.Dispose();
            aboutFont.Dispose();
        }
开发者ID:Coolcord,项目名称:Clicktastic,代码行数:48,代码来源:Clicktastic.cs

示例5: Show

        /// <summary>
        /// Show editor for config management
        /// </summary>
        public void Show()
        {
            configForm = new Form();
            buttonClose = new Button();
            buttonCancel = new Button();
            dgView = new DataGridView();

            dgView.Parent = configForm;
            dgView.BringToFront();
            dgView.RowHeadersVisible = false;
            buttonCancel.Parent = configForm;
            buttonClose.Parent = configForm;

            configForm.Text = "Config Editor";
            configForm.FormBorderStyle = FormBorderStyle.FixedDialog;
            configForm.MaximizeBox = false;
            configForm.MinimizeBox = false;
            configForm.StartPosition = FormStartPosition.CenterParent;

            Parameterlist.Clear();
            SetSize();

            dgView.Rows.Clear();
            try
            {
                Parameterlist = Read();
            }
            catch
            {
                MessageBox.Show("File Not Found, creating SQL default");
                InitSQLDefaults();
                Parameterlist = Read();
            }

            dgView.Columns.Add("dgName", "Name");
            dgView.Columns.Add("dgValue", "Value");
            dgView.Columns["dgName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgView.Columns["dgName"].FillWeight = 40;
            dgView.Columns["dgValue"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dgView.Columns["dgValue"].FillWeight = 60;

            foreach (CParameter x in Parameterlist)
            {
                dgView.Rows.Add();
                dgView.Rows[dgView.Rows.Count - 2].Cells[0].Value = x.Name;
                dgView.Rows[dgView.Rows.Count - 2].Cells[1].Value = x.Value;
            }

            buttonClose.Click += new EventHandler(buttonClose_Click);
            buttonCancel.Click += new EventHandler(buttonCancel_Click);
            dgView.KeyDown += new KeyEventHandler(dgView_KeyDown);

            configForm.ShowDialog();

            configForm.Dispose();
            buttonClose.Dispose();
            buttonCancel.Dispose();
            dgView.Dispose();
            GC.Collect();
        }
开发者ID:Raxo94,项目名称:QCView,代码行数:63,代码来源:CConfig.cs

示例6: FocusTest

		public void FocusTest ()
		{
			Form f = null;
			Button c = null, d = null;

			try {
				f = new Form ();
				f.ShowInTaskbar = false;
				f.Visible = true;
				c = new Button ();
				c.Visible = true;
				f.Controls.Add (c);

				d = new Button ();
				d.Visible = false;
				f.Controls.Add (d);

				Assert.IsTrue (c.CanFocus, "Focus1");
				Assert.IsFalse (c.Focused, "Focus2");
				c.Focus ();
				Assert.IsTrue (c.Focused, "Focus3");
				d.Focus ();
				Assert.IsFalse (d.Focused, "Focus4");

				d.Visible = true;
				d.Focus ();
				Assert.IsTrue (d.Focused, "Focus5");
				Assert.IsFalse (c.Focused, "Focus6");

				c.Enabled = false;
				Assert.IsFalse (c.Focused, "Focus7");
			} finally {
				if (f != null)
					f.Dispose ();
				if (c != null)
					c.Dispose ();
				if (d != null)
					d.Dispose ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:40,代码来源:ControlTest.cs

示例7: lblStatus_Click

        private void lblStatus_Click(object sender, EventArgs e)
        {
            Form aboutForm = new Form() { FormBorderStyle = FormBorderStyle.FixedSingle, MinimizeBox = false, MaximizeBox = false };
            aboutForm.StartPosition = FormStartPosition.CenterParent;
            aboutForm.Width = 400;
            aboutForm.Height = 200;
            aboutForm.Text = "About Internet Tester";
            aboutForm.Icon = Internet_Tester.Properties.Resources.Internet_Tester;

            //Get the version number
            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

            Label aboutText = new Label()
            {
                Width = 400,
                Height = 130,
                Location = new Point(0, 0),
                ImageAlign = ContentAlignment.MiddleCenter,
                TextAlign = ContentAlignment.MiddleCenter,
                Text = "Internet Tester v" + fileVersionInfo.ProductMajorPart + "." + fileVersionInfo.ProductMinorPart + "." + fileVersionInfo.ProductBuildPart + "\n\n" +
                    "A Simple Program to Quickly\n" + "Check the Internet Connection\n\n" +
                    "Programmed and Designed by Coolcord"
            };
            Font aboutFont = new Font("Microsoft Sans Serif", 8, FontStyle.Bold);
            aboutText.Font = aboutFont;
            Button btnOk = new Button() { Width = 100, Height = 30, Text = "OK", Location = new Point(150, 130), ImageAlign = ContentAlignment.MiddleCenter, TextAlign = ContentAlignment.MiddleCenter };
            btnOk.Click += (btnSender, btnE) => aboutForm.Close(); //click ok to close
            aboutForm.AcceptButton = btnOk;
            aboutForm.Controls.Add(aboutText);
            aboutForm.Controls.Add(btnOk);
            aboutForm.ShowDialog();
            aboutForm.Dispose();
            btnOk.Dispose();
            aboutText.Dispose();
            aboutFont.Dispose();
        }
开发者ID:Coolcord,项目名称:Internet_Tester,代码行数:37,代码来源:InternetTester.cs

示例8: ShowForm


//.........这里部分代码省略.........
                            maxRight = System.Math.Max(maxRight, copyright.Rectangle.Right);
                            maxBottom = System.Math.Max(maxBottom, copyright.Rectangle.Bottom);
                            _infoLines.Add(copyright);
                        }
                    }

                    int buttonMinRight = 7;

                    //Close button
                    buttonClose = new Button() { Padding = new Padding(3, 1, 3, 1) };
                    buttonClose.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
                    buttonClose.AutoSize = true;
                    buttonClose.DialogResult = DialogResult.OK;
                    buttonClose.Text = Resources.Close;
                    form.Controls.Add(buttonClose);
                    buttonMinRight += buttonClose.Width + 11;

                    //Readme button
                    var readMePath = GetReadMePath();
                    if (readMePath != null) {
                        buttonReadme = new Button() { Padding = new Padding(3, 1, 3, 1) };
                        buttonReadme.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                        buttonReadme.AutoSize = true;
                        buttonReadme.Text = Resources.ReadMe;
                        buttonReadme.Tag = readMePath;
                        buttonReadme.Click += new EventHandler(buttonReadme_Click);
                        form.Controls.Add(buttonReadme);
                        buttonMinRight += buttonReadme.Width + 7;
                    }

                    //WebPage button
                    if (webpage != null) {
                        buttonWebPage = new Button() { Padding = new Padding(3, 1, 3, 1) };
                        buttonWebPage.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                        buttonWebPage.AutoSize = true;
                        buttonWebPage.Text = Resources.WebPage;
                        buttonWebPage.Tag = webpage.ToString();
                        buttonWebPage.Click += new EventHandler(buttonWebPage_Click);
                        form.Controls.Add(buttonWebPage);
                        buttonMinRight += buttonWebPage.Width + 7;
                    }

                    maxRight = System.Math.Max(maxRight, buttonMinRight);

                    int borderX = (form.Width - form.ClientRectangle.Width);
                    int borderY = (form.Height - form.ClientRectangle.Height);
                    form.Width = borderX + maxRight + 7;
                    form.Height = borderY + maxBottom + 11 + 11 + buttonClose.Size.Height + 7;
                    if (owner == null) {
                        form.StartPosition = FormStartPosition.CenterScreen;
                    } else {
                        form.StartPosition = FormStartPosition.CenterParent;
                    }

                    int buttonLeft = form.ClientRectangle.Left + 7;

                    if (buttonReadme != null) {
                        buttonReadme.Location = new Point(buttonLeft, form.ClientRectangle.Bottom - buttonClose.Height - 7);
                        buttonLeft += buttonReadme.Width + 7;
                    }

                    if (buttonWebPage != null) {
                        buttonWebPage.Location = new Point(buttonLeft, form.ClientRectangle.Bottom - buttonClose.Height - 7);
                        buttonLeft += buttonWebPage.Width + 7;
                    }

                    buttonClose.Location = new Point(form.ClientRectangle.Right - buttonClose.Width - 7, form.ClientRectangle.Bottom - buttonClose.Height - 7);

                    form.AcceptButton = buttonClose;
                    form.CancelButton = buttonClose;

                    form.Paint += Form_Paint;

                    if (owner != null) {
                        Form formOwner = owner as Form;
                        if ((formOwner != null) && (formOwner.TopMost == true)) {
                            form.TopMost = false;
                            form.TopMost = true;
                        }
                        form.ShowDialog(owner);
                    } else {
                        form.ShowDialog();
                    }
                } finally {
                    if (buttonClose != null) { buttonClose.Dispose(); }
                    if (buttonReadme != null) { buttonReadme.Dispose(); }
                    if (buttonWebPage != null) { buttonWebPage.Dispose(); }

                    if (fullName != null) { fullName.Dispose(); }
                    if (dotNetFramework != null) { dotNetFramework.Dispose(); }
                    if (osVersion != null) { osVersion.Dispose(); }
                    if (copyright != null) { copyright.Dispose(); }

                    if (_paintImage != null) { _paintImage.Dispose(); }
                    if (_paintProduct != null) { _paintProduct.Dispose(); }

                    if (productFont != null) { productFont.Dispose(); }
                }
            }
        }
开发者ID:WORawSon,项目名称:VhdAttach,代码行数:101,代码来源:AboutBox+[014].cs

示例9: RemoveZoom

		protected void RemoveZoom(ref Button btn)
		{
			if (btn != null)
			{
				btn.Hide();
				btn.Dispose();
				btn = null;    // reset zoom window
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:9,代码来源:DisplayUnicodeNamesForm.cs

示例10: RemoveFocus

 public void RemoveFocus()
 {
     Button btn = new Button();
     btn.Parent = this;
     btn.Left = -9999;
     btn.Top = -9999;
     btn.Focus();
     btn.Dispose();
 }
开发者ID:450640526,项目名称:HtmExplorer,代码行数:9,代码来源:Win32AddressBar.cs


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