Home > Blockchain >  How Do You Edit a Second (Non-Main) C# Form Window In Visual Studio Designer?
How Do You Edit a Second (Non-Main) C# Form Window In Visual Studio Designer?

Time:07-02

I am writing a C# Windows Forms program in Visual Studio. I have a button that creates and shows (opens) a new Form (window) called VideoWindow. I can edit the MainWindow in the Design workspace in Visual Studio which allows me to visually edit its contents. However, I can't find a way to do the same thing with the VideoWindow. I have tried right clicking on VideoWindow and clicking View Designer, but it just takes me to the MainWindow designer. How do I open the designer for the second VideoWindow? Is this possible? Below is the code that creates and opens the new form:

    private void ButtonWindow(object sender, EventArgs e)
    {
        Form VideoWindow = new Form();
        VideoWindow.Size = new Size(500, 300);
        VideoWindow.Show();
    }

CodePudding user response:

You can customize a new form, and then create the corresponding object after modification. Here are the relevant steps:

1.Create a new form videoform enter image description here

2.Relevant code:

.Show(); and .ShowDialog(); Note the difference between the two.

private void button1_Click(object sender, EventArgs e)
{
    VideoWindow videoWindow = new VideoWindow();
    videoWindow.Show();
    //videoWindow.ShowDialog();
}

3.Ouput: enter image description here

  • Related