-1
フォルダを開いて結果をテキストボックスに入れようとしています。 しかし、ユーザーがフォルダを選択し、[OK]を押した場合、私がチェックしたときに、それは私にエラーを与えるC245の条件式が 'System :: Windows :: Forms :: DialogResult'型が不正です。
C245 conditional expression of type 'System::Windows::Forms::DialogResult' is illegal
これは、エラーは、私はちょうどDialogResultでそれをも試してみました
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
if (result = System::Windows::Forms::DialogResult::OK)
{
textBox1->Text = folderBrowserDialog1->SelectedPath;
}
}
};
ある部分であります:: OKですが、OKが宣言されていないというエラーメッセージが表示され、Googleを検索するとSystem :: Windows :: Forms :: DialogResult :: OKを代わりに使用する必要があります。
そして、これが
#pragma once
#using <System.DLL>
#using <System.Drawing.DLL>
#using <System.Windows.Forms.DLL>
namespace MyProject {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for ConfigureScreen
/// </summary>
public ref class ConfigureScreen : public System::Windows::Forms::Form
{
public:
ConfigureScreen(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~ConfigureScreen()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::FolderBrowserDialog^ folderBrowserDialog1;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::Button^ button1;
protected:
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->folderBrowserDialog1 = (gcnew System::Windows::Forms::FolderBrowserDialog());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//Forbid the user to create new folders when using folder browser.
this->folderBrowserDialog1->ShowNewFolderButton = false;
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(32, 96);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(234, 20);
this->textBox1->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(272, 94);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"Browse";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &ConfigureScreen::button1_Click);
//
// ConfigureScreen
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(422, 345);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Name = L"ConfigureScreen";
this->Text = L"ConfigureScreen";
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Windows::Forms::DialogResult result = folderBrowserDialog1->ShowDialog();
if (result = System::Windows::Forms::DialogResult::OK)
{
textBox1->Text = folderBrowserDialog1->SelectedPath;
}
}
};
}
ありがとうそんなに:) –