// Show the Open File dialog. If the user clicks
OK, load the
// picture that the user chose.
(openFileDialog1.ShowDialog() == DialogResult.OK)
it always throws an error;
Error 1 'PictureViewer.Form1' does not contain a definition for 'openFileDialog1_FileOk' and no extension method 'openFileDialog1_FileOk' accepting a first argument of type 'PictureViewer.Form1' could be found (are you missing a using directive
or an assembly reference?) C:\Documents and Settings\Home User\my documents\visual studio 2010\Projects\PictureViewer\PictureViewer\Form1.Designer.cs 148 94 PictureViewer
This is as if I had not performed Step 7 where the OpenFileDialog is inserted, yet it has been and is visible and shows up in the Form1.Designer.cs;
I'm able to reproduce this by doubleclicking the openFileDialog1-Control in the designer and the deleting the automatically generated mehtod-stub-code in the code-view.
To get rid of this error, you'll have to edit the file "Form1.Designer.cs". In the Project-Explorer doubleclick the Form1.Designer.cs-file (if not shown in the Project-Explorer, click the small Triangle in front of "Form1.cs").
In the now opened code-view of that file, search for the line: (it's in the method: InitializeComponent, maybe you'll have to click one of the small "+" signs at the beginning of a #region generated by the WinFormsDesigner)
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
and remove it. This will remove the handler for that event, and the program should run now.
Edit: You can also navigate to the code-line I mentioned above by doubleclicking the error message.
Marked as answer byNancy ShaoThursday, August 26, 2010 8:46 AM