Menu Item

  • Thread starter Thread starter kronecker
  • Start date Start date
K

kronecker

I have a problem loading a file from the Menu item. In fact I just
copied from another program where it works.

Private Sub toolStripMenuItemLoadSession_Click(ByVal sender As
Object, ByVal e As EventArgs) Handles
toolStripMenuItemLoadSession.Click
Try
Dim fi As New FileInfo(Application.ExecutablePath)
openFileDialogDump.InitialDirectory = fi.DirectoryName
openFileDialogDump.AddExtension = True
openFileDialogDump.DefaultExt = "xml"
openFileDialogDump.FileName = "UserSession.xml"
Dim dr As DialogResult = openFileDialogDump.ShowDialog(Me)
If dr = System.Windows.Forms.DialogResult.OK Then

Me.myUser.Predicates.loadSettings(openFileDialogDump.FileName)
End If
Catch ex As Exception
Me.richTextBoxOutput.Text += ex.Message &
Environment.NewLine
End Try
End Sub

I get the error that openFileDialogDump does not exist. Any ideas?

K.
 
Kronecker

Did you drag an openFileDialog on your surface and give it the name as used
in the code?

Cor
 
I have a problem loading a file from the Menu item. In fact I just
copied from another program where it works.

Private Sub toolStripMenuItemLoadSession_Click(ByVal sender As
Object, ByVal e As EventArgs) Handles
toolStripMenuItemLoadSession.Click
Try
Dim fi As New FileInfo(Application.ExecutablePath)
openFileDialogDump.InitialDirectory = fi.DirectoryName
openFileDialogDump.AddExtension = True
openFileDialogDump.DefaultExt = "xml"
openFileDialogDump.FileName = "UserSession.xml"
Dim dr As DialogResult = openFileDialogDump.ShowDialog(Me)
If dr = System.Windows.Forms.DialogResult.OK Then

Me.myUser.Predicates.loadSettings(openFileDialogDump.FileName)
End If
Catch ex As Exception
Me.richTextBoxOutput.Text += ex.Message &
Environment.NewLine
End Try
End Sub

I get the error that openFileDialogDump does not exist. Any ideas?

K.

Make sure you named your OpenFileDialog component as
"openFileDialogDump" in properties window which is dragged-dropped on
your form from toolbox.

Or, instantiate OpenFileDialog class with the name of your variable in
your "try" block as:

Dim openFileDialogDump As New OpenFileDialog

...then use it.


Thanks,

Onur Güzel
 
Back
Top