本文整理汇总了C#中System.Windows.Forms.Label.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Label.Dispose方法的具体用法?C# Label.Dispose怎么用?C# Label.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Label
的用法示例。
在下文中一共展示了Label.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: dataGridView1_CellDoubleClick
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
Label lb = new Label();
lb.AutoSize = true;
lb.Margin = new Padding(3, 3, 3, 3);
lb.BorderStyle = BorderStyle.FixedSingle;
lb.Text = string.Format("{0} - {1}", this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString());
lb.Tag = string.Format("{0} {1}", this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString(), this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString());
OnButtonClick lbClick = (object sender1, EventArgs e1) =>
{
lb.Dispose();
};
lb.DoubleClick += new EventHandler(lbClick);
this.flowLayoutPanel1.Controls.Add(lb);
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
MessageBox.Show(ex.Message);
return;
}
}
示例2: button1_Click
private void button1_Click(object sender, EventArgs e)
{
Label tmp;
for (int i = 0; i < 200; i++)
{
tmp = new Label();
tmp.Dispose();
}
GC.Collect();
}
示例3: GetDropdownWidth
public static int GetDropdownWidth(IEnumerable<string> values)
{
int maxWidth = 0;
int temp = 0;
Label label1 = new Label();
label1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
foreach (var val in values)
{
label1.Text = val;
temp = label1.PreferredWidth;
if (temp > maxWidth)
{
maxWidth = temp;
}
}
label1.Dispose();
return maxWidth;
}
示例4: Filter_DropDown
private void Filter_DropDown(object sender, EventArgs e)
{
var cb = sender as ComboBox;
if (cb == null)
return;
int maxWidth = 0;
int temp = 0;
Label label1 = new Label();
foreach (var obj in cb.Items)
{
label1.Text = obj.ToString();
temp = label1.PreferredWidth;
if (temp > maxWidth)
maxWidth = temp;
}
label1.Dispose();
if (maxWidth > cb.Width)
cb.DropDownWidth = maxWidth;
}
示例5: MessageShowAgain
public static DialogResult MessageShowAgain(string title, string promptText)
{
Form form = new Form();
System.Windows.Forms.Label label = new System.Windows.Forms.Label();
CheckBox chk = new CheckBox();
Controls.MyButton buttonOk = new Controls.MyButton();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2));
form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
form.Text = title;
label.Text = promptText;
chk.Tag = ("SHOWAGAIN_" + title.Replace(" ", "_"));
chk.AutoSize = true;
chk.Text = "Show me again?";
chk.Checked = true;
chk.Location = new Point(9, 80);
if (MainV2.config[(string)chk.Tag] != null && (string)MainV2.config[(string)chk.Tag] == "False") // skip it
{
form.Dispose();
chk.Dispose();
buttonOk.Dispose();
label.Dispose();
return DialogResult.OK;
}
chk.CheckStateChanged += new EventHandler(chk_CheckStateChanged);
buttonOk.Text = "OK";
buttonOk.DialogResult = DialogResult.OK;
buttonOk.Location = new Point(form.Right - 100, 80);
label.SetBounds(9, 40, 372, 13);
label.AutoSize = true;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, chk, buttonOk });
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
ThemeManager.ApplyThemeTo(form);
DialogResult dialogResult = form.ShowDialog();
form.Dispose();
form = null;
return dialogResult;
}
示例6: DropDownWidth
// wrapper to handle the width of the combo box
int DropDownWidth(ComboBox myCombo)
{
int maxWidth = 0;
int temp = 0;
Label label_test = new Label();
foreach (var obj in myCombo.Items)
{
label_test.Text = obj.ToString();
temp = label_test.PreferredWidth;
if (temp > maxWidth)
maxWidth = temp;
}
label_test.Dispose();
return maxWidth;
}
示例7: OnReceive
//.........这里部分代码省略.........
sfxPlayer.Initialize(wr);
if (!mute)
sfxPlayer.Play();
for (int x = 0; x <= 64; x++)
{
testimonyPB.Location = new Point(256 - (4 * x), 3);
//icon.Location = new Point(256 + 6 - (2 * x), 3 + 5);
//name.Location = new Point(256 + 91 - (2 * x), 3 + 8);
//note.Location = new Point(256 + 92 - (2 * x), 3 + 26);
//desc.Location = new Point(256 + 9 - (2 * x), 3 + 81);
icon.Refresh();
name.Refresh();
note.Refresh();
desc.Refresh();
}
System.Threading.Thread.Sleep(3000);
for (int x = 0; x <= 64; x++)
{
testimonyPB.Location = new Point(0 - (4 * x), 3);
//icon.Location = new Point(6 - (2 * x), 3 + 5);
//name.Location = new Point(91 - (2 * x), 3 + 8);
//note.Location = new Point(92 - (2 * x), 3 + 26);
//desc.Location = new Point(9 - (2 * x), 3 + 81);
icon.Refresh();
name.Refresh();
note.Refresh();
desc.Refresh();
}
testimonyPB.Image = null;
name.Dispose();
icon.Dispose();
desc.Dispose();
note.Dispose();
}
else
{
Data msgReceived = new Data(byteData);
//Accordingly process the message received
switch (msgReceived.cmdCommand)
{
case Command.Login:
break;
case Command.Logout:
break;
case Command.ChangeMusic:
if (msgReceived.strMessage != null && msgReceived.strMessage != "" & msgReceived.strName != null)
{
appendTxtLogSafe("<<<" + msgReceived.strName + " changed the music to " + msgReceived.strMessage + ">>>\r\n");
musicReader = new DmoMp3Decoder("base/sounds/music/" + msgReceived.strMessage);
if (musicPlayer.PlaybackState != PlaybackState.Stopped)
musicPlayer.Stop();
musicPlayer.Initialize(musicReader);
if (!mute)
musicPlayer.Play();
}
break;
case Command.ChangeHealth:
示例8: 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;
}
示例9: GetKeyDialog
//.........这里部分代码省略.........
timer.Enabled = true;
timer.Elapsed += (sender, e) =>
{
try
{
this.Invoke(new MethodInvoker(() =>
{
switch (textState)
{ //add dots to the end of the message as time passes
case 0:
lblKey.Text = message;
break;
case 1:
lblKey.Text = message + ".";
break;
case 2:
lblKey.Text = message + "..";
break;
case 3:
lblKey.Text = message + "...";
break;
}
}));
textState = (textState + 1) % 4;
}
catch { }
};
KEYCOMBO key = new KEYCOMBO();
Keys lastKey = Keys.None;
key.valid = false; //assume invalid unless otherwise stated
string strKey = null;
keyPrompt.PreviewKeyDown += (sender, e) =>
{
timer.Stop();
//Determine the key pressed
strKey = keyStringConverter.KeyToString(e.KeyCode);
//Determine key modifiers
if (e.Alt && e.KeyCode != Keys.Menu)
strKey = "Alt + " + strKey;
if (e.Shift && e.KeyCode != Keys.ShiftKey)
strKey = "Shift + " + strKey;
if (e.Control && e.KeyCode != Keys.ControlKey)
strKey = "Ctrl + " + strKey;
lblKey.Text = strKey;
lastKey = e.KeyCode;
};
keyPrompt.KeyDown += (sender, e) =>
{
if (e.Modifiers.Equals(Keys.Alt))
{
e.Handled = true; //don't open the menu with alt
}
};
keyPrompt.KeyUp += (sender, e) =>
{
keyPrompt.Close();
};
lblKey.MouseClick += (sender, e) =>
{
timer.Stop();
if (e.Button == MouseButtons.Left)
strKey = "LeftClick";
else if (e.Button == MouseButtons.Right)
strKey = "RightClick";
else if (e.Button == MouseButtons.Middle)
strKey = "MiddleClick";
else
return; //button not recognized
string strLastKey = lblKey.Text.Split(' ').Last();
if (strLastKey == "Ctrl" || strLastKey == "Shift" || strLastKey == "Alt")
strKey = lblKey.Text + " + " + strKey;
lblKey.Text = strKey;
lastKey = Keys.None;
keyPrompt.Close();
};
keyPrompt.MouseWheel += (sender, e) =>
{
timer.Stop();
if (e.Delta < 0) //negative is down
strKey = "MouseWheelDown";
else //positive is up
strKey = "MouseWheelUp";
string strLastKey = lblKey.Text.Split(' ').Last();
if (strLastKey == "Ctrl" || strLastKey == "Shift" || strLastKey == "Alt")
strKey = lblKey.Text + " + " + strKey;
lblKey.Text = strKey;
lastKey = Keys.None;
keyPrompt.Close();
};
keyPrompt.ShowDialog();
//All done with the dialog
keyPrompt.Dispose();
lblKey.Dispose();
key = ParseKEYCOMBO(strKey, lastKey);
return key;
}
示例10: magnify
private void magnify()
{
try
{
if ((this.zoom.Width >= 5) && (this.zoom.Height >= 5))
{
this.picBox.Dock = DockStyle.None;
Graphics graphics1 = this.picBox.CreateGraphics();
int num1 = 0x10;
int num2 = this.picBox.Width;
int num3 = this.picBox.Height;
int num4 = this.pnlImg.Width / this.zoom.Width;
int num5 = this.pnlImg.Height / this.zoom.Height;
if (num4 > num1)
{
num4 = num1;
}
if (num5 > num1)
{
num5 = num1;
}
this.picBox.Width = num2 * num4;
this.picBox.Height = num3 * num5;
Label label1 = new Label();
label1.Location = new Point(this.zoom.Left, this.zoom.Top);
label1.Size = new Size(this.zoom.Width, this.zoom.Height);
label1.Name = "label";
label1.Text = "LABEL!ADDED!";
label1.Visible = true;
this.pnlImg.Controls.Add(label1);
this.pnlImg.ScrollControlIntoView(label1);
graphics1.DrawImageUnscaled(this.bmp, 0, 0);
this.picBox.Invalidate();
graphics1.Dispose();
label1.Dispose();
}
}
catch (Exception exception1)
{
MessageBox.Show("Error: " + exception1.Message, "Error!");
}
}
示例11: Disk
//Disk - wmi query for Win32_LogicalDisk
public string Disk()
{
string s = "";
string sLetter = "";
string sFSType = "";
string query = "SELECT * FROM Win32_LogicalDisk WHERE FileSystem IS NOT NULL";
ManagementObjectSearcher seeker = new ManagementObjectSearcher(query);
ManagementObjectCollection oReturnCollection = seeker.Get();
int i = 0;
System.Windows.Forms.Label lTemp = new System.Windows.Forms.Label(); //temporary lable for getting the necessary max size of pbar
lTemp.AutoSize = true;
foreach (ManagementObject m in oReturnCollection)
{
sLetter = m["DeviceID"].ToString();
sFSType = m["FileSystem"].ToString();
s += sLetter + " " + CalcSize(m["FreeSpace"].ToString(), 1) + " " + sFSType + "\n";
if (bHDDPBar == true)
{
long iFS = Convert.ToInt64(m["FreeSpace"]);
long iSize = Convert.ToInt64(m["Size"]);
if (iSize > 0)
_hddBar[i].Value = Convert.ToInt16((100 * (iSize - iFS) / iSize)); //percent used space: 100* (size - free space) / size
//if you want display free space: 100* freespace / size
else
_hddBar[i].Value = 100;
if (_hddBar[i].Value <= 50)
_pHddProg[i].Color = cColorHDDBar50;
if (_hddBar[i].Value > 50 && _hddBar[i].Value <= 75)
_pHddProg[i].Color = cColorHDDBar75;
if (_hddBar[i].Value > 75)
_pHddProg[i].Color = cColorHDDBar100;
_hddBar[i].Text = sLetter + " " + CalcSize(iFS.ToString(), 1) + " " + sFSType;
_hddBar[i].Name = _hddBar[i].Text + "\r\n" + "Size: " + CalcSize(iSize.ToString(), 1); //used for tooltip text
i++;
}
}
oReturnCollection.Dispose();
seeker.Dispose();
lTemp.Text = s;
_pHddBack.Color = cColorHDDBack;
for (int k = 0; k < 10; k++)
{
if (k < i)
{
if (bColorGlobal)
{
_hddBar[k].Font = fFontGlobal;
lTemp.Font = fFontGlobal;
}
else
{
_hddBar[k].Font = fTitleFont[3];
lTemp.Font = fTitleFont[3];
}
_hddBar[k].Height = Convert.ToInt16(_hddBar[k].Font.GetHeight()) + 2;
_hddBar[k].Width = lTemp.PreferredWidth + 10; //size all bars to max necessary size
_hddBar[k].Top = _hddBar[k].Height * k; //position the bar
_hddBar[k].ForeColor = cColorHDDText;
_hddBar[k].Visible = true;
_hddBar[k].BringToFront();
_hddBar[k].Update();
}
else
_hddBar[k].Visible = false;
}
lTemp.Dispose();
lTemp = null;
return s;
}
示例12: 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();
}
示例13: dropDownWidth
/// <summary>
/// Funcion que nos devuelve el tamaño para ajustar un comboBox al texto
/// </summary>
/// <param name="myCombo">Recice el comboBox del cual queremos saber el tamaño</param>
/// <returns></returns>
private int dropDownWidth(ComboBox myCombo)
{
int maxWidth = 0;
int temp = 0;
Label label1 = new Label();
foreach (KeyValuePair<String, String> item in myCombo.Items)
{
label1.Text = item.Value;
temp = label1.PreferredWidth + 20;
if (temp > maxWidth)
{
maxWidth = temp;
}
}
label1.Dispose();
return maxWidth;
}
示例14: 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();
}
示例15: Hauptfenster_Load
private void Hauptfenster_Load(object sender, EventArgs e)
{
// Init script types
comboBox_script_type.Items.AddRange(Info.ScriptTemplate);
comboBox_script_type.SelectedIndex = 0;
comboBox_script_type.DropDownStyle = ComboBoxStyle.DropDownList;
// already done by selected index changed
//Datastores.ReloadDB();
//UpdateNPCListBox();
// set width of the combo
int maxWidth = 0;
int temp = 0;
Label label_test = new Label();
foreach (var obj in comboBox_script_type.Items)
{
label_test.Text = obj.ToString();
temp = label_test.PreferredWidth;
if (temp > maxWidth)
maxWidth = temp;
}
label_test.Dispose();
comboBox_script_type.DropDownWidth = maxWidth;
}