Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Open File dialog error?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    29

    Resolved [RESOLVED] [2005] Open File dialog error?

    Hi.. I'm having problem with open file dialog

    When I first open the program then select(browse) the files, if I press the cancel button, the entry files are not selected(not go to the data grid), but after the first try, if I cancel, the entry from the first try got inserted, Is this bug? I've used filedialog.dispose()..
    I've tried to put the dispose after showdialog() but it still doesn't work..

    here's the code

    Code:
            FileDialog.ShowDialog()
    
            total = FileDialog.FileNames.Length
            uplot = New String(total) {}
            If total > 0 Then
                dgv_uplot.Rows.Add(total)
            End If
    
            FileDialog.Dispose()
    
            For i = 0 To total - 1
                uplot(i) = Me.filedialog.FileNames(i).ToString
    
                dgv_uplot.Item(1, baris).Value = uplot(i)
                baris += 1
            Next
    
            FileDialog.Dispose()

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    The code inside if statement will get executed only if the user selected a file and presses ok .
    Code:
    If FileDialog.ShowDialog() = DialogResult.OK Then 
    
            total = FileDialog.FileNames.Length
            uplot = New String(total) {}
            If total > 0 Then
                dgv_uplot.Rows.Add(total)
            
            For i = 0 To total - 1
                uplot(i) = Me.filedialog.FileNames(i).ToString
    
                dgv_uplot.Item(1, baris).Value = uplot(i)
                baris += 1
            Next
    
    End If

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    29

    Re: [2005] Open File dialog error?

    Quote Originally Posted by Pirate
    The code inside if statement will get executed only if the user selected a file and presses ok .
    Code:
    If FileDialog.ShowDialog() = DialogResult.OK Then 
    
            total = FileDialog.FileNames.Length
            uplot = New String(total) {}
            If total > 0 Then
                dgv_uplot.Rows.Add(total)
            
            For i = 0 To total - 1
                uplot(i) = Me.filedialog.FileNames(i).ToString
    
                dgv_uplot.Item(1, baris).Value = uplot(i)
                baris += 1
            Next
    
    End If
    Thanks.. It's working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width