本文整理汇总了C#中TextBox.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.SetBounds方法的具体用法?C# TextBox.SetBounds怎么用?C# TextBox.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextBox
的用法示例。
在下文中一共展示了TextBox.SetBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public static DialogResult Show(string title, string promptText, ref string value, InputBoxValidation validation)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button button = new Button();
Button button1 = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
button.Text = "OK";
button1.Text = "Cancel";
button.DialogResult = DialogResult.OK;
button1.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
button.SetBounds(228, 72, 75, 23);
button1.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
button.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
Control.ControlCollection controls = form.Controls;
Control[] controlArray = new Control[] { label, textBox, button, button1 };
controls.AddRange(controlArray);
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;
form.AcceptButton = button;
form.CancelButton = button1;
if (validation != null)
{
form.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => {
if (form.DialogResult == DialogResult.OK)
{
string text = validation(textBox.Text);
bool flag = text != "";
bool flag1 = flag;
e.Cancel = flag;
if (flag1)
{
MessageBox.Show(form, text, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
textBox.Focus();
}
}
});
}
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
示例2: Show
public static DialogResult Show(string title, string promptText, ref string value,
InputBoxValidation validation)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
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;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
if (validation != null) {
form.FormClosing += delegate(object sender, FormClosingEventArgs e) {
if (form.DialogResult == DialogResult.OK) {
string errorText = validation(textBox.Text);
if (e.Cancel = (errorText != "")) {
MessageBox.Show(form, errorText, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox.Focus();
}
}
};
}
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
示例3: ToolTipExam
public ToolTipExam()
{
tooltip = new ToolTip();
btn = new Button();
btn.Parent = this;
btn.SetBounds(10, 10, 100, 30);
btn.Text = "버튼";
btn.Click += new EventHandler(btn_Click);
txt = new TextBox();
txt.Parent = this;
txt.SetBounds(10, 50, 200, 100);
txt.Text = "이름을 입력하세요>>";
tooltip.SetToolTip(btn, "버튼을 클릭해 보세요!!"); // 컨트롤과 툴팁연결
tooltip.SetToolTip(txt, "이름을 입력하는 부분입니다.");
}
示例4: InputBox
public static DialogResult InputBox(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
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;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
示例5: ListBoxExam
public ListBoxExam()
{
listBox1 = new ListBox();
checkedListBox1 = new CheckedListBox();
txt_info = new TextBox();
listBox1.Parent = this;
listBox1.SetBounds(10, 10, 50, 100);
listBox1.SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
checkedListBox1.Parent = this;
checkedListBox1.SetBounds(70, 10, 50, 100);
checkedListBox1.SelectedIndexChanged += new EventHandler(SelectedIndexChanged);
txt_info.Parent = this;
txt_info.SetBounds(10, 120, 300, 120);
txt_info.Multiline = true;
for (int i = 0; i < str1.Length; i++)
listBox1.Items.Add(str1[i]);
for (int j = 0; j < str2.Length; j++)
checkedListBox1.Items.Add(str2[j]);
}