本文整理汇总了C#中TextBox.BringToFront方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.BringToFront方法的具体用法?C# TextBox.BringToFront怎么用?C# TextBox.BringToFront使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBox
的用法示例。
在下文中一共展示了TextBox.BringToFront方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
//.........这里部分代码省略.........
buttons[c].Location = new Point(x, y);
workingArea.Controls.Add(buttons[c]);
}
#endregion
#region Filename label
//define the label
Font filenameFont = new Font("Arial", 10, FontStyle.Bold);
Label filenameLabel = new Label() {
Text = "Filename:",
Font = filenameFont
};
//define the location of the label to be at the beginning and centered
//vertically.
int filenameX = padding;
int filenameY = (workingArea.Height - inputRegionHeight) +
(inputRegionHeight / 2) - (((int)filenameFont.GetHeight() + 1) / 2);
filenameLabel.Location = new Point(filenameX, filenameY);
workingArea.Controls.Add(filenameLabel);
//calculate the end position x position of the label
//so we know were to position the text box
int filenameEndX = 75;//filenameLabel.Width + (padding * 2);
#endregion
#region Filename text box
TextBox filenameTextBox = new TextBox() {
BorderStyle = BorderStyle.FixedSingle,
Text = "New file"
};
//position the text box in the middle of the input region
int txtX = filenameEndX;
int txtY = (workingArea.Height - inputRegionHeight) +
(inputRegionHeight / 2) - (filenameTextBox.Height / 2);
filenameTextBox.Location = new Point(txtX, txtY);
//stretch the width of the text box
filenameTextBox.Width =
workingArea.Width - currentButtonX - filenameEndX - padding;
//add the text box
workingArea.Controls.Add(filenameTextBox);
filenameTextBox.BringToFront();
#endregion
bool cancelled = true;
/*Define the events for the buttons and text box*/
cancelButton.Click += delegate(object sender, EventArgs e) { form.Close(); };
addButton.Click += delegate(object sender, EventArgs e) { validate(filenameTextBox, form, ref cancelled); };
list.KeyDown += delegate(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Escape) { form.Close(); }
};
filenameTextBox.KeyDown += delegate(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Enter) { validate(filenameTextBox, form, ref cancelled); }
if (e.KeyCode == Keys.Escape) { form.Close(); }
};
/*Define the selection change event for the list so that
when the user selects an item, it automatically adds
the extension in filename*/
list.ItemSelectionChanged += delegate(object sender, ListViewItemSelectionChangedEventArgs e) {
if (e.Item == null) { return; }
//define the new extesion
string newExt = (string)e.Item.Tag;
//add the extension to the filename
string[] fileSplit = filenameTextBox.Text.Split('.');
if (fileSplit.Length == 1) {
Array.Resize(ref fileSplit, fileSplit.Length + 1);
}
fileSplit[fileSplit.Length - 1] = newExt;
//new extension is blank?
if (newExt == "") {
Array.Resize(ref fileSplit, fileSplit.Length - 1);
}
//set the new filename
filenameTextBox.Text = Helpers.Flatten(fileSplit, ".");
};
/*Define tab indexes*/
filenameTextBox.TabIndex = 0;
cancelButton.TabIndex = 1;
addButton.TabIndex = 2;
list.TabIndex = 3;
//show the form and await user interaction.
form.ShowDialog();
//return what the filename was if the user didnt cancel
//the dialog.
return (cancelled ? null : filenameTextBox.Text);
}