Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. DragDrop zip file onto DataGridView

DragDrop zip file onto DataGridView

Scheduled Pinned Locked Moved Visual Basic
csharpcomdebugging
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    penguin5000
    wrote on last edited by
    #1

    Hi, I've got some code that allows me to click a button to browse to a zip file, and populate a DataGridView with all of the file names contained within the zip. What I now want to do is go a stage further, and allow the user to drag a zip file into the DataGridView, and perform the same routine. For reference, the functionality to perform the unzip is provided via DotNetZipLib.zip The code that I've been trying to get to work is: Imports ionic.utils.zip Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop Dim strFilePathAndName As String strFilePathAndName = DirectCast(e.Data.GetData(Windows.Forms.DataFormats.FileDrop), String) Dim zip As ZipFile zip = ZipFile.Read(strFilePathAndName) Dim tblZipFilesTable As DataTable = New DataTable("CompressedFiles") Dim ds As DataSet = New DataSet("ZipFile") ds.Tables.Add(tblZipFilesTable) tblZipFilesTable.Columns.Add("File name", GetType(String)) tblZipFilesTable.Columns.Add("Columns in table", GetType(Integer)) Dim tblRow As DataRow For Each file As ZipEntry In zip tblRow = tblZipFilesTable.NewRow tblRow.Item("File name") = file.FileName.ToString tblZipFilesTable.Rows.Add(tblRow) Next Me.DataGridView1.DataSource = ds Me.DataGridView1.DataMember = "CompressedFiles" With Me.DataGridView1 .Columns(0).Width = 210 .Columns(1).Width = 120 End With Me.DataGridView1.Refresh() End Sub Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter If e.Data.GetDataPresent(Windows.Forms.DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub But it doesn't do anything. When I set a breakpoint within the first few lines of "Sub DataGridView1_DragDrop", I find that it doesn't even go in here.

    P 1 Reply Last reply
    0
    • P penguin5000

      Hi, I've got some code that allows me to click a button to browse to a zip file, and populate a DataGridView with all of the file names contained within the zip. What I now want to do is go a stage further, and allow the user to drag a zip file into the DataGridView, and perform the same routine. For reference, the functionality to perform the unzip is provided via DotNetZipLib.zip The code that I've been trying to get to work is: Imports ionic.utils.zip Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop Dim strFilePathAndName As String strFilePathAndName = DirectCast(e.Data.GetData(Windows.Forms.DataFormats.FileDrop), String) Dim zip As ZipFile zip = ZipFile.Read(strFilePathAndName) Dim tblZipFilesTable As DataTable = New DataTable("CompressedFiles") Dim ds As DataSet = New DataSet("ZipFile") ds.Tables.Add(tblZipFilesTable) tblZipFilesTable.Columns.Add("File name", GetType(String)) tblZipFilesTable.Columns.Add("Columns in table", GetType(Integer)) Dim tblRow As DataRow For Each file As ZipEntry In zip tblRow = tblZipFilesTable.NewRow tblRow.Item("File name") = file.FileName.ToString tblZipFilesTable.Rows.Add(tblRow) Next Me.DataGridView1.DataSource = ds Me.DataGridView1.DataMember = "CompressedFiles" With Me.DataGridView1 .Columns(0).Width = 210 .Columns(1).Width = 120 End With Me.DataGridView1.Refresh() End Sub Private Sub DataGridView1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragEnter If e.Data.GetDataPresent(Windows.Forms.DataFormats.FileDrop) Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End Sub But it doesn't do anything. When I set a breakpoint within the first few lines of "Sub DataGridView1_DragDrop", I find that it doesn't even go in here.

      P Offline
      P Offline
      penguin5000
      wrote on last edited by
      #2

      Resolved it ... Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop Dim strFilePathAndName As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop), String()) Dim zip As ZipFile zip = ZipFile.Read(strFilePathAndName(0))

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups