© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
6 replies
XE SparkyCracked

✅ Winforms: open two forms at the same time

Good day everyone. So I have an issue (duhh, thats why I am here xD).

I am trying to get a screenshot of the users image...I am using two forms to achieve this, one to show the image and another to screenshot.
When I try open the first form
AspectRatioForm
AspectRatioForm
and then the second
SelectArea
SelectArea
. It throws the issue below:
System.ArgumentException: 'Parameter is not valid.'
System.ArgumentException: 'Parameter is not valid.'


This is the code I wrote:
public void openImageScreenshot(string imageLocationPath, PictureBox pictureBox)
{
    SelectArea area = new SelectArea(this);
   
    area.BringToFront();
    area.Activate();
    
    using (Image img = Image.FromFile(imageLocationPath))
    {
        AspectRatioForm aspectRatioForm = new AspectRatioForm(img);
        aspectRatioForm.Show();
    }
    this.Hide();
    area.ShowDialog();
    // After showing and hiding the SelectArea form, you can access the file path:
    string imagePathScreenshot = area.GetScreenshotFilePath();
    pictureBox.ImageLocation = imagePathScreenshot;
    this.Show();
}
public void openImageScreenshot(string imageLocationPath, PictureBox pictureBox)
{
    SelectArea area = new SelectArea(this);
   
    area.BringToFront();
    area.Activate();
    
    using (Image img = Image.FromFile(imageLocationPath))
    {
        AspectRatioForm aspectRatioForm = new AspectRatioForm(img);
        aspectRatioForm.Show();
    }
    this.Hide();
    area.ShowDialog();
    // After showing and hiding the SelectArea form, you can access the file path:
    string imagePathScreenshot = area.GetScreenshotFilePath();
    pictureBox.ImageLocation = imagePathScreenshot;
    this.Show();
}


Now I don't know why this is happening because if I call them separately in terms of their own functions using
ShowDialog
ShowDialog
they both show one by one (once one form closes the other will show).
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Animating both values at the same time
C#CC# / help
2y ago
❔ Iteration over multiple objects at the same time
C#CC# / help
3y ago
❔ ✅ break 2 for cycles at the same time
C#CC# / help
3y ago