Click here to Skip to main content
15,911,711 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
hi all,
i convert a search project from c# to VC++.Net but there is 1 error i can't find the answer..
in my project i have browse button but doesn't save the file which i pick it.. there is 1 instruction in the code can't convert it ..
this is the instruction (DialogResult1.OK)

and this is the code for the browse button :

C#
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 if (openFileDialog1->ShowDialog() == DialogResult1.OK)
            {
                textBox1->Text = openFileDialog1->FileName;
                StreamReader ^sr =gcnew StreamReader(textBox1->Text);
                textBox4->Text = sr->ReadToEnd();
            }



and this is the error :
MSIL
error C2228: left of '.OK' must have class/struct/union
1>        type is 'System::Windows::Forms::DialogResult ^'


please help me..thanx :D:D
Posted
Updated 17-May-11 13:19pm
v2
Comments
Sergey Alexandrovich Kryukov 17-May-11 19:19pm    
Tag it! The language is called C++/CLI!
--SA

If this is C++ then you should probably use ::DialogResult::OK

See this (has examples in C++ and C#):
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.dialogresult.aspx#Y953[^]
 
Share this answer
 
Comments
OriginalGriff 17-May-11 11:25am    
5!
Albert Holguin 17-May-11 11:29am    
thanks :)
ENG.Dido 17-May-11 12:22pm    
thnx albert..there is no error now but the browse button doesn't work :P
ENG.Dido 17-May-11 12:42pm    
looooooooool i forget to change click property for button1..thank u albert..it's work now :D:D
Albert Holguin 17-May-11 12:57pm    
cool! :)
Take the '1' out:
if (openFileDialog1->ShowDialog() == DialogResult1.OK)
Becomes
if (openFileDialog1->ShowDialog() == DialogResult.OK)
 
Share this answer
 
Comments
Albert Holguin 17-May-11 11:15am    
is this valid for C++? ...see my solution...
OriginalGriff 17-May-11 11:25am    
:doh: Yes - you are right!
You need to remove the '1' and change to ::DialogResult::OK
ENG.Dido 17-May-11 12:23pm    
like albert's said :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900