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


C# Button.SetBounds方法代码示例

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


在下文中一共展示了Button.SetBounds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
	}
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:54,代码来源:InputBox.cs

示例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;
  }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:53,代码来源:InputBox.cs

示例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, "이름을 입력하는 부분입니다.");
    }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:18,代码来源:Program.cs

示例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;
    }
开发者ID:danlb2000,项目名称:Atari-Disk-Explorer,代码行数:41,代码来源:InputBox.cs

示例5: buildGameField

        private void buildGameField()
        {
            int start_pos_x = 1;
            int start_pos_y = 1;
            int button_width = 75;
            int button_height = 75;

            int current_pos_x = start_pos_x;
            int current_pos_y = start_pos_y;

            Button button;

            for (int j = 0; j < field_size; j++)
            {
                current_pos_x = start_pos_x;
                for (int i = 0; i < field_size; i++)
                {
                    button = new Button();

                    button.Name = "button" + i.ToString();

                    button.Tag = i; //We identify each button with its tag property and initialize it with the index value

                    button.SetBounds(current_pos_x, current_pos_y, button_width, button_height);
                    button.Text = "";

                    button.Click += new EventHandler(button_Click);

                    this.Controls.Add(button);

                    buttons[i, j] = button;
                    xo_matrix[i, j] = -1;

                    current_pos_x += button_width + 1;
                }
                current_pos_y += button_height + 1;
            }

            this.Refresh();
        }
开发者ID:hecatonheyrus,项目名称:mindvalley_tests,代码行数:40,代码来源:Form1.cs

示例6: TabControlExam

    public TabControlExam()
    {
        this.Text = "TabControl 예제";

        tabControl = new TabControl();
        tabControl.Selected += new TabControlEventHandler(tabControl_Selected);

        tabPage1 = new TabPage();
        tabPage1.Text = "첫번째 Tab";
        tabPage1.BackColor = Color.Brown;
        btn_tabpage1 = new Button();
        btn_tabpage1.Text = "버튼을 클릭하세요!";
        btn_tabpage1.SetBounds(30, 60, 150, 50);
        btn_tabpage1.BackColor = Color.White;
        btn_tabpage1.Parent = tabPage1;
        btn_tabpage1.Click += new System.EventHandler(btn_tabpage1_Click);

        tabPage2 = new TabPage();
        tabPage2.Text = "두번째 Tab";
        tabPage2.Paint += new PaintEventHandler(tabPage2_Paint);

        // TabControl에 Tabpage를 추가
        tabControl.Controls.AddRange(new Control[] { tabPage1, tabPage2 });

        // AddRange 대신 속성을 통한 추가 가능
        //tabPage1.Parent = tabControl;
        //tabPage2.Parent = tabControl;

        tabControl.Location = new Point(25, 25);
        tabControl.Size = new Size(250, 250);

        this.ClientSize = new Size(300, 300);

        // TabContrl을 윈폼에 출력하는 코드
        Controls.AddRange(new Control[] { this.tabControl });

        // 위의 코드와 동일 처리
        //tabControl.Parent = this;
    }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:39,代码来源:Program.cs


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