Menu Item

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kronecker@yahoo.co.uk

    #1

    Menu Item

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

    Private Sub toolStripMenuIt emLoadSession_C lick(ByVal sender As
    Object, ByVal e As EventArgs) Handles
    toolStripMenuIt emLoadSession.C lick
    Try
    Dim fi As New FileInfo(Applic ation.Executabl ePath)
    openFileDialogD ump.InitialDire ctory = fi.DirectoryNam e
    openFileDialogD ump.AddExtensio n = True
    openFileDialogD ump.DefaultExt = "xml"
    openFileDialogD ump.FileName = "UserSession.xm l"
    Dim dr As DialogResult = openFileDialogD ump.ShowDialog( Me)
    If dr = System.Windows. Forms.DialogRes ult.OK Then

    Me.myUser.Predi cates.loadSetti ngs(openFileDia logDump.FileNam e)
    End If
    Catch ex As Exception
    Me.richTextBoxO utput.Text += ex.Message &
    Environment.New Line
    End Try
    End Sub

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

    K.
  • Cor Ligthert [MVP]

    #2
    Re: Menu Item

    Kronecker

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

    Cor

    <kronecker@yaho o.co.ukschreef in bericht
    news:ec71b0c7-dc06-4912-a779-8fded9af34d8@b2 g2000prf.google groups.com...
    >I have a problem loading a file from the Menu item. In fact I just
    copied from another program where it works.
    >
    Private Sub toolStripMenuIt emLoadSession_C lick(ByVal sender As
    Object, ByVal e As EventArgs) Handles
    toolStripMenuIt emLoadSession.C lick
    Try
    Dim fi As New FileInfo(Applic ation.Executabl ePath)
    openFileDialogD ump.InitialDire ctory = fi.DirectoryNam e
    openFileDialogD ump.AddExtensio n = True
    openFileDialogD ump.DefaultExt = "xml"
    openFileDialogD ump.FileName = "UserSession.xm l"
    Dim dr As DialogResult = openFileDialogD ump.ShowDialog( Me)
    If dr = System.Windows. Forms.DialogRes ult.OK Then
    >
    Me.myUser.Predi cates.loadSetti ngs(openFileDia logDump.FileNam e)
    End If
    Catch ex As Exception
    Me.richTextBoxO utput.Text += ex.Message &
    Environment.New Line
    End Try
    End Sub
    >
    I get the error that openFileDialogD ump does not exist. Any ideas?
    >
    K.

    Comment

    • kimiraikkonen

      #3
      Re: Menu Item

      On Aug 8, 10:54 am, kronec...@yahoo .co.uk wrote:
      I have a problem loading a file from the Menu item. In fact I just
      copied from another program where it works.
      >
      Private Sub toolStripMenuIt emLoadSession_C lick(ByVal sender As
      Object, ByVal e As EventArgs) Handles
      toolStripMenuIt emLoadSession.C lick
      Try
      Dim fi As New FileInfo(Applic ation.Executabl ePath)
      openFileDialogD ump.InitialDire ctory = fi.DirectoryNam e
      openFileDialogD ump.AddExtensio n = True
      openFileDialogD ump.DefaultExt = "xml"
      openFileDialogD ump.FileName = "UserSession.xm l"
      Dim dr As DialogResult = openFileDialogD ump.ShowDialog( Me)
      If dr = System.Windows. Forms.DialogRes ult.OK Then
      >
      Me.myUser.Predi cates.loadSetti ngs(openFileDia logDump.FileNam e)
      End If
      Catch ex As Exception
      Me.richTextBoxO utput.Text += ex.Message &
      Environment.New Line
      End Try
      End Sub
      >
      I get the error that openFileDialogD ump does not exist. Any ideas?
      >
      K.
      Make sure you named your OpenFileDialog component as
      "openFileDialog Dump" 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 openFileDialogD ump As New OpenFileDialog

      ...then use it.


      Thanks,

      Onur Güzel

      Comment

      Working...