Home
Options

windows Forms texbox

Hi
I begin to code with C#and i need to know if we can create a form ( uwp , xaml ,real form) with textbox without using initialize helper (Form designer) inside linQPad ?
Thank's

Comments

  • Options

    Yes, you can. Here's a basic WinForms form.

    public class Form1 : Form
    {
        private Button Button1 = new Button();
        private Label Label1 = new Label();
    
        public Form1()
        {
            Button1.Width = 120;
            Button1.Height = 20;
            Button1.Top = 24;
            Button1.Text = "Click Me";
    
            Label1.Width = 120;
            Label1.Height = 20;
            Label1.Text = "Not Yet Clicked";
    
            this.Controls.Add(Label1);
            this.Controls.Add(Button1);
        }
    }
    

    You can also do this in VS too.

  • Options

    And to show the form in LINQPad, add the following code to the start of your query:

    new Form1().Show();
    

    or:

    new Form1().ShowDialog();
    
Sign In or Register to comment.