0

I use this code to open a FileDialog, choose a file and press OK.

It works fine, but when I press OK in the fileDialog, the FileDialog doesn´t close after pressing OK the first time. The dialog blinks one time and are still open.
The second time I press OK, the openfileDialog will close.

What can I do to make it close when I press OK the first time ?

openFileDialog1->ShowDialog();

 if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
	
	 textBox5->Text = openFileDialog1->FileName;
}
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Lukezzz
0

Didn't you see that you show TWO open file dialog windows? You close the 1st dialog and immediately show the 2nd one in if expression...
What for the 1st line of your snippet?

Please, next time use code tag properly:
[code=c++] text

[/code]

0

I see, I thought by first show the dialog and THEN make an if statement of what was choosen in the dialog.
But this works well. Thank you for help...

if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
	
	 textBox5->Text = openFileDialog1->FileName;
}

Didn't you see that you show TWO open file dialog windows? You close the 1st dialog and immediately show the 2nd one in if expression...
What for the 1st line of your snippet?

Please, next time use code tag properly:
[code=c++] text

[/code]

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.