tec*_*ner 4 managed visual-c++ winforms
我是第一次使用Managed C++ ...我使用Winform创建了一个表单,它有一个按钮来浏览目录中的文件以及用户选择的路径,该路径应该在文本框中可见.
我想知道如何在托管C++中创建文件浏览器对话框.
如果需要,附加表单的图像.

您正在寻找OpenFileDialog或SaveFileDialog.
void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 2;
openFileDialog1->RestoreDirectory = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
if ( (myStream = openFileDialog1->OpenFile()) != nullptr )
{
// Insert code to read the stream here.
myStream->Close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8850 次 |
| 最近记录: |