When I start up the program I have added code to open a file dialog box, but doing this results in the main form being sent behind Visual Studio(and other open programs) once a file has been selected.
I have tried using this.BringToFront()
but this doesn't seem to work.
The program currently only has one form as well, how would I bring this to the front when the program starts?
public Form1()
{
InitializeComponent();
InitialiseDataGrid();
selectFile();
readData();
this.BringToFront();
}
selectFile()
is a function that selects a file using a file dialog box,
readData()
is a function that reads the data from the text file into a dataGridView
.
You should past the owner window's instance while Opening The dialog window. example code:
var file = new OpenFileDialog();
file.ShowDialog(this);