I've created a simple WinForms app in visual studio and I've run into the issue of during runtime, my Winforms changes form or something?
When coding in visual studio and not running the code, it looks like this which is what I'm used to:
When I run my code, the form looks like this, which to me looks more windows 10ish, and I have no idea why.
The runtime form appears as if the minimum size has not been set correctly(which it has) and also the border around the form looks different.
Both of these issues are new to me even though I've been building simple WinForms programs as plugins for another program for over a year now. Perhaps the other program has something to do with it. I'm self-taught so bear with me.
I've recently tried to add a work GitHub account to my personal laptop so I can write code for both my personal and work projects. I don't think the two items are related.
So far,
I've tried removing the System.Windows.Forms reference and then re-adding it.
I've tried cleaning and rebuilding it.
I've tried messing with FormBorderStyle but that doesn't seem to help anything appearance-wise.
I found this post cause it looked liked similar and I tried putting the
Application.EnableVisualStyles();
before calling the.ShowDialog()
and also tried putting it in the form.Load() function just out of desperation but no luck.
This seems like it could be a relatively simple solution but I'm just not finding it.
Update - 20210808-2222 PST
Context: Running Parallels Windows 10 through macbookpro.
Visual Studio - .NET Framework 4.7.2
End of Update
Update - 20210809-2735 PST
So from the comments that have come in, I've tried the following:
inserting Application.EnableVisualStyles();
at the beginning of Main. but nothing seems to change, my forms still show up the same.
I also tried inserting Application.Application.SetHighDpiMode()
but this is for .NET 5
. I am using .Net Framework 4.7.2
As i looked through the links posted in the comments. A number of them mentioned a .xml
file but my form only has a .Designer.cs
and a .resx
.
Although basic, here some code for reference in case it helps.
namespace ConsoleApp1
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// select folder
// todo: switch to commonOpenFileDialg https://stackoverflow.com/questions/11624298/how-to-use-openfiledialog-to-select-a-folder
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
folderBrowserDialog.RootFolder = Environment.SpecialFolder.DesktopDirectory;
folderBrowserDialog.Description = "Please select a folder that cones the files you would like rename";
folderBrowserDialog.ShowDialog();
// User picks a folder
if (!folderBrowserDialog.SelectedPath.Equals(""))
{
Form1 form1 = new Form1();
form1.ShowDialog(); // more stuff happens in the form.
}
}
}
}
**End of update
Any help and/or direction is appreciated.