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


C# TextBox.Dispose方法代码示例

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


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

示例1: createLongTwitImage

        public static Image createLongTwitImage(TextBox tbWeibo)
        {
            //获取图片长度
            Graphics g = Graphics.FromHwnd(tbWeibo.Handle);
            int tmptbHeight;

            try
            {
                tmptbHeight = (int)g.MeasureString(tbWeibo.Text + "\r\n\r\n\t\t\tBy #SinaWeiboClient#", tbWeibo.Font, 440).Height;
            }
            catch
            {
                return null;
            }
            finally
            {
                g.Dispose();
            }

            //生成文本框
            TextBox tmptb = new TextBox();
            tmptb.Multiline = true;
            tmptb.Width = 440;
            tmptb.Height = tmptbHeight;
            tmptb.Text = tbWeibo.Text + "\r\n\r\n\t\t\tBy #SinaWeiboClient#";
            tmptb.BackColor = Color.White;
            tmptb.BorderStyle = BorderStyle.None;

            //转化为图片
            Bitmap bmp = new Bitmap(tmptb.Width, tmptb.Height);
            Rectangle rect = new Rectangle(new Point(0, 0), tmptb.Size);
            tmptb.DrawToBitmap(bmp, rect);
            tmptb.Dispose();

            //MeasureString方法不甚精准,消除底部空白
            int lines = 0, pixels = 0, white = Color.White.ToArgb();
            for (int i = bmp.Height; i > 0; i--, pixels = 0)
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    if (bmp.GetPixel(j, i).ToArgb() == white)
                        pixels++;
                    else
                        pixels = 0;
                }
                if (pixels == bmp.Width)
                    lines++;
                else
                    break;
            }

            return lines > 0 ? bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height - lines), System.Drawing.Imaging.PixelFormat.Format24bppRgb) : bmp;
        }
开发者ID:rayel,项目名称:SinaWeiboClient,代码行数:53,代码来源:LongTwits.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: OnKeyPress

        public void OnKeyPress(object sender, KeyPressEventArgs e)
        {
            string hexChars = "0123456789ABCDEF";

            if (textBoxString1.ContainsFocus | textBoxString2.ContainsFocus
                | textBoxString3.ContainsFocus |textBoxString4.ContainsFocus)
            { // ignore typing in textboxes
                return;
            }
            
            // check for copy/cut
            if ((e.KeyChar == 3) || (e.KeyChar == 24))
            {
                textBoxDisplay.Copy();
                return;
            }

            if (radioButtonDisconnect.Checked)
            { // don't do anything else if not connected
                return;
            }

            textBoxDisplay.Focus();
            
            if (radioButtonHex.Checked)
            { // hex mode
                string charTyped = e.KeyChar.ToString();    // get typed char
                charTyped = charTyped.ToUpper();
                if (charTyped.IndexOfAny(hexChars.ToCharArray()) == 0)
                { // valid Hex character
                    if (labelTypeHex.Visible)
                    { // first nibble already typed - send byte
                        string dataString = labelTypeHex.Text.Substring(11,1) + charTyped;
                        labelTypeHex.Text = "Type Hex : ";
                        labelTypeHex.Visible = false;
                        byte[] hexByte = new byte[1];
                        hexByte[0] = (byte)Utilities.Convert_Value_To_Int("0x" + dataString);
                        dataString = "TX:  " + dataString + "\r\n";
                        textBoxDisplay.AppendText(dataString);
                        textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length;
                        textBoxDisplay.ScrollToCaret();
                        if (logFile != null)
                        {
                            logFile.Write(dataString);
                        }
                        Pk2.DataDownload(hexByte, 0, hexByte.Length);
                    }
                    else
                    { // show first nibble
                        labelTypeHex.Text = "Type Hex : " + charTyped + "_";
                        labelTypeHex.Visible = true;
                    }
                }
                else
                { // other char - clear typed hex
                    labelTypeHex.Text = "Type Hex : ";
                    labelTypeHex.Visible = false;
                }
            }
            else
            { // ASCII mode
                // check for paste
                if (e.KeyChar == 22)
                {
                    textBoxDisplay.SelectionStart = textBoxDisplay.Text.Length; //cursor at end
                    TextBox tempBox = new TextBox();
                    tempBox.Multiline = true;
                    tempBox.Paste();
                    do
                    {
                        int pasteLength = tempBox.Text.Length;
                        if (pasteLength > 60)
                        {
                            pasteLength = 60;
                        }
                        sendString(tempBox.Text.Substring(0, pasteLength), false);
                        tempBox.Text = tempBox.Text.Substring(pasteLength);
                        
                        // wait according to the baud rate so we don't overflow the download buffer
                        float baud = float.Parse((comboBoxBaud.SelectedItem.ToString()));
                        baud = (1F / baud) * 12F * (float)pasteLength; // to ensure we don't overflow, give each byte 12 bits
                        baud *= 1000F; // baud is now in ms.
                        Thread.Sleep((int)baud);
                    } while (tempBox.Text.Length > 0);
                    
                    tempBox.Dispose();
                    return;
                }
                
                string charTyped = e.KeyChar.ToString();
                if (charTyped == "\r")
                {
                    charTyped = "\r\n";
                }
                sendString(charTyped, false);
            }
        }
开发者ID:timwuu,项目名称:PK2BL32,代码行数:97,代码来源:DialogUART.cs

示例4: GetControls

        private List<Control> GetControls(GUIDField field, Size canvasSize)
        {
            TextBox textBox = new TextBox();
            MaskedTextBox maskedTextBox = new MaskedTextBox();

            if (field is IPatternable && !(string.IsNullOrEmpty(((IPatternable)field).Pattern)))
            {
                textBox.Dispose();
                maskedTextBox.HidePromptOnLeave = true;
                maskedTextBox.Text = string.Empty;
                maskedTextBox.BorderStyle = borderStyle;
                //maskedTextBox.MaskInputRejected += new MaskInputRejectedEventHandler(maskedTextBox_MaskInputRejected);
                maskedTextBox.Mask = AppData.Instance.DataPatternsDataTable.GetMaskByPattern(((IPatternable)field).Pattern);

                SetControlProperties(maskedTextBox, field, canvasSize);
                Label maskedPrompt = GetPrompt(maskedTextBox, field, canvasSize);
                List<Control> maskedControls = new List<Control>();
                maskedControls.Add(maskedPrompt);
                maskedControls.Add(maskedTextBox);
                if (!fieldControls.ContainsKey(field))
                {
                    fieldControls.Add(field, maskedControls);
                }
                else
                {
                    fieldControls.Remove(field);
                    fieldControls.Add(field, maskedControls);
                }
                return maskedControls;
            }
            else
            {
                maskedTextBox.Dispose();

                if (field is GUIDField)
                {
                    if (field.CurrentRecordValueString.Equals(string.Empty))
                    {
                        //textBox.Text = field.NewGuid().ToString();
                    }
                    else
                    {
                        textBox.Text = field.CurrentRecordValueString.Replace(StringLiterals.CURLY_BRACE_LEFT,string.Empty).Replace(StringLiterals.CURLY_BRACE_RIGHT, string.Empty);
                    }
                    textBox.ReadOnly = ((GUIDField)field).IsReadOnly;
                    textBox.MaxLength = ((GUIDField)field).MaxLength;
                }

                SetControlProperties(textBox, field, canvasSize);
                textBox.ReadOnly = true;
                textBox.BorderStyle = borderStyle;
                Label prompt = GetPrompt(textBox, field, canvasSize);
                List<Control> controls = new List<Control>();
                controls.Add(prompt);
                controls.Add(textBox);
                if (!fieldControls.ContainsKey(field))
                {
                    fieldControls.Add(field, controls);
                }
                else
                {
                    fieldControls.Remove(field);
                    fieldControls.Add(field, controls);
                }
                return controls;
            }
        }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:67,代码来源:ControlFactory.cs

示例5: HandleLabelEditClick

 private void HandleLabelEditClick(DynamicList list)
 {
     if (this.allowLabelEdit)
     {
         TextBox txt = new TextBox();
         txt.Text = this.Text;
         this.AssignControlUntilFocusChange(txt);
         if (this.BeginLabelEdit != null)
         {
             this.BeginLabelEdit(this, new DynamicListEventArgs(list));
         }
         bool escape = false;
         txt.KeyDown += delegate (object sender2, KeyEventArgs e2) {
             if ((e2.KeyData == Keys.Return) || (e2.KeyData == Keys.Escape))
             {
                 e2.Handled = true;
                 if (e2.KeyData == Keys.Escape)
                 {
                     if (this.CanceledLabelEdit != null)
                     {
                         this.CanceledLabelEdit(this, new DynamicListEventArgs(list));
                     }
                     escape = true;
                 }
                 this.Control = null;
                 txt.Dispose();
             }
         };
         txt.LostFocus += delegate {
             if (!escape)
             {
                 this.Text = txt.Text;
                 if (this.FinishLabelEdit != null)
                 {
                     this.FinishLabelEdit(this, new DynamicListEventArgs(list));
                 }
             }
         };
     }
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:40,代码来源:DynamicListItem.cs

示例6:

        private void cancelbutton_click
            (object sender, EventArgs e, WebClient client,PictureBox cancelbutton,
            ProgressBar progressbar,string filename,TextBox episode = null)
        {
            const string message = "确定取消下载么?";
            const string caption = "取消下载";
            if (cancelbutton.Name.StartsWith("batch"))
            {
                client.CancelAsync();
                client.Dispose(); //without it, deleting file would fail.
                batchpanel.Controls.Remove(episode);
                batchpanel.Controls.Remove(cancelbutton);
                batchpanel.Controls.Remove(progressbar);
                cancelbutton.Dispose();
                progressbar.Dispose();
                episode.Dispose();
                File.Delete(filename);
            }
            else 
            {
                var result = System.Windows.Forms.MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    client.CancelAsync();
                    client.Dispose();
                    infopanel.Controls.Remove(cancelbutton);
                    infopanel.Controls.Remove(progressbar);
                    cancelbutton.Dispose();
                    progressbar.Dispose();
                    File.Delete(filename);
                }
            }

        }
开发者ID:polyval,项目名称:ESLPodcast,代码行数:34,代码来源:MainForm.cs

示例7: checkDuplicateName

        private void checkDuplicateName(TextBox txtName)
        {
            Regex testName = new Regex("^[A-z][0-9A-z]*$");

            if (!testName.Match(txtName.Text).Success)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Please enter valid name for this object\nThe name must be alphanumeric", "Warning");
                txtName.Focus();
                txtName.SelectAll();
                return;
            }

            bool isDuplicate = false;

            foreach (Control c in parentPanel.Controls)
            {
                //Kiểm tra tên đối với những Notation cùng loại
                if (c.GetType().Name == namingShape.GetType().Name && c != namingShape)
                    if (((ShapeBase)c).sName.ToLower() == txtName.Text.ToLower())
                    {
                        isDuplicate = true;
                        break;
                    }
            }
            if (!isDuplicate)
            {
                //nếu nó là attribute (viết tạm ở đây)
                if (this is AttributeShape)
                {
                    AttributeShape att = this as AttributeShape;

                    if (att.attributeChilds.Count == 0)
                    {
                        att.dataType = ucDataDescription.cboDataType.SelectedItem.ToString();
                        if (ucDataDescription.txtLength.Text != "")
                        {
                            try
                            {
                                int length = int.Parse(ucDataDescription.txtLength.Text);
                                //if ((att.dataType == "nvarchar" || att.dataType == "nchar") && (length < 1 || length > 4000))
                                //{
                                //    DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 4000.", "Warning");
                                //    return;
                                //}
                                //if (length < 1 || length > 8000)
                                //{
                                //    DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 8000.", "Warning");
                                //    return;
                                //}
                                if (length < 1)
                                {
                                    DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length greater than 0", "Warning");
                                    return;
                                }
                                att.dataLength = length;
                            }
                            catch
                            {
                                DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length as positive number.", "Warning");
                                return;
                            }
                        }
                        else
                            att.dataLength = 0;

                        att.allowNull = ucDataDescription.chkNull.Checked;
                        att.description = ucDataDescription.txtDescription.Text;

                        ucDataDescription.Dispose();
                    }
                }

                this.sName = txtName.Text;

                //auto size to bound name
                Graphics g = CreateGraphics();
                SizeF nameSize = g.MeasureString(sName, ThongSo.JFont);
                if (nameSize.Width + 30 > ThongSo.ShapeW)
                    this.Width = (int)nameSize.Width + 30;

                txtName.Dispose();
                parentPanel.isNaming = false;
                parentPanel.Refresh();
                this.Invalidate();
            }
            else
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Object " + txtName.Text + " already exist", "Warning");
                txtName.Focus();
                txtName.SelectAll();
            }
        }
开发者ID:rsuneja,项目名称:erdesigner,代码行数:92,代码来源:ShapeBase.cs

示例8: RefreshAll_TriggersRetrieveHotSpotEventForAllEnabled

		public void RefreshAll_TriggersRetrieveHotSpotEventForAllEnabled()
		{
			TextBox textBox1 = new TextBox();
			TextBox textBox2 = new TextBox();
			TextBox textBox3 = new TextBox();
			TextBox textBox4 = new TextBox();

			_hotSpotProvider.SetEnableHotSpots(textBox1, true);
			_hotSpotProvider.SetEnableHotSpots(textBox2, false);
			_hotSpotProvider.SetEnableHotSpots(textBox3, false);
			_hotSpotProvider.SetEnableHotSpots(textBox4, true);

			bool retrieveHotSpots1Called = false;
			bool retrieveHotSpots2Called = false;
			bool retrieveHotSpots3Called = false;
			bool retrieveHotSpots4Called = false;

			_hotSpotProvider.RetrieveHotSpots +=
				delegate(object sender, RetrieveHotSpotsEventArgs e)
					{
						if (e.Control == textBox1)
						{
							retrieveHotSpots1Called = true;
							return;
						}
						if (e.Control == textBox2)
						{
							retrieveHotSpots2Called = true;
							return;
						}
						if (e.Control == textBox3)
						{
							retrieveHotSpots3Called = true;
							return;
						}
						if (e.Control == textBox4)
						{
							retrieveHotSpots4Called = true;
							return;
						}
						throw new InvalidOperationException();
					};

			// reset since installing the handler causes it to fire.
			retrieveHotSpots1Called = false;
			retrieveHotSpots2Called = false;
			retrieveHotSpots3Called = false;
			retrieveHotSpots4Called = false;

			// force hotSpotProvider to retrieve HotSpots
			_hotSpotProvider.RefreshAll();

			Assert.IsTrue(retrieveHotSpots1Called);
			Assert.IsFalse(retrieveHotSpots2Called);
			Assert.IsFalse(retrieveHotSpots3Called);
			Assert.IsTrue(retrieveHotSpots4Called);

			textBox1.Dispose();
			textBox2.Dispose();
			textBox3.Dispose();
			textBox4.Dispose();
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:62,代码来源:HotSpotProviderTests.cs

示例9: HandleLabelEditClick

		void HandleLabelEditClick(DynamicList list)
		{
			if (!allowLabelEdit)
				return;
			TextBox txt = new TextBox();
			txt.Text = this.Text;
			AssignControlUntilFocusChange(txt);
			if (BeginLabelEdit != null)
				BeginLabelEdit(this, new DynamicListEventArgs(list));
			bool escape = false;
			txt.KeyDown += delegate(object sender2, KeyEventArgs e2) {
				if (e2.KeyData == Keys.Enter || e2.KeyData == Keys.Escape) {
					e2.Handled = true;
					if (e2.KeyData == Keys.Escape) {
						if (CanceledLabelEdit != null)
							CanceledLabelEdit(this, new DynamicListEventArgs(list));
						escape = true;
					}
					this.Control = null;
					txt.Dispose();
				}
			};
			txt.LostFocus += delegate {
				if (!escape) {
					this.Text = txt.Text;
					if (FinishLabelEdit != null)
						FinishLabelEdit(this, new DynamicListEventArgs(list));
				}
			};
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:30,代码来源:DynamicListItem.cs

示例10: OnParentChanged

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine whether or not this control has been placed on a toolstrip control.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void OnParentChanged(EventArgs e)
		{
			base.OnParentChanged(e);

			Control parent = Parent;

			// Determine whether or not the control is hosted on a toolstrip.
			while (parent != null)
			{
				if (parent is ToolStrip)
				{
					m_fParentIsToolstrip = true;
					DockPadding.All = 1;
					btnScrPsgDropDown.Width = kButtonWidthOnToolstrip;
					MouseEnter += txtScrRef_MouseEnter;
					MouseLeave += txtScrRef_MouseLeave;
					SizeChanged += HandleSizeChanged;
					return;
				}

				parent = parent.Parent;
			}

			m_fParentIsToolstrip = false;
			TextBox txtTmp = new TextBox();
			txtScrRef.Font = txtTmp.Font.Clone() as Font;
			txtTmp.Dispose();

			DockPadding.All = (Application.RenderWithVisualStyles ?
				SystemInformation.BorderSize.Width : SystemInformation.Border3DSize.Width);

			btnScrPsgDropDown.Dock = DockStyle.Right;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:38,代码来源:ScrPassageControl.cs


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