Author Topic: DotNET DataGridViews And Some Other Specific Stuff  (Read 1889 times)

0 Members and 1 Guest are viewing this topic.

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
DotNET DataGridViews And Some Other Specific Stuff
« on: August 10, 2011, 10:15:45 pm »
Okay. So some of you know my program BNDSRM that helps you manage ROMs and stuff. So I have been planning on changing the listboxes to DataGridViews so I can have information in multiple columns. I have an idea how I am going to set it up and how I was going to fill the boxes and stuff, but its like an information overload kinda thing. I can see how I am going to do it, but I just stop and am like... How... How... I don't know.

I am using Visual Basic .NET I started this program in it and I am planning to finish it all the way until v1.0.0 in VB.NET and then rewrite it in C# .NET.

I need help with taking information and filling the DataGridView (4 columns), with the number of the ROM, the Name (of the file minus extension), the size, and the type of file it is (taken from the extension). I have For loop setup to list files in a listbox, looking at it, it looked like I could reuse most of the code but I just gave up after stalling (I have a tendency to do that).

Here is my function for listing the files:
Code: [Select]
    Private Sub ListFiles(ByVal folderPath As String, ByVal exten() As String)
        ListBox1.Items.Clear()
        For Each fileEX As String In exten
            Dim fileNames = My.Computer.FileSystem.GetFiles(folderPath, FileIO.SearchOption.SearchTopLevelOnly, fileEX)
            For Each filename As String In fileNames
                Dim inSlash As Long
                Dim arry = 0
                inSlash = InStrRev(filename, "\")
                filename = Mid(filename, inSlash + 1)
                ListBox1.Items.Add(filename)
                Dim array(0 To 9999) As String
                array(arry) = filename
                arry += 1
            Next
        Next
    End Sub

If you need more info, please ask.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: DotNET DataGridViews And Some Other Specific Stuff
« Reply #1 on: August 10, 2011, 10:20:16 pm »
You're resetting "arry" each time you go through the loop; did you want to do that?

Offline XVicarious

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +45/-28
  • I F**king Love Twisty Puzzles
    • View Profile
    • XVicarious
Re: DotNET DataGridViews And Some Other Specific Stuff
« Reply #2 on: August 10, 2011, 10:21:16 pm »
Lol I don't even know.  It works like that right now as it is.

Offline BlakPilar

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 734
  • Rating: +44/-1
    • View Profile
Re: DotNET DataGridViews And Some Other Specific Stuff
« Reply #3 on: August 10, 2011, 11:48:16 pm »
Sorry for my delay, but I was on a roll coming up with syntax for YANOOPL ;) (...and had summer work)

Assuming your columns are in the exact order you mentioned (number, name, size, type), then this might work for you (I haven't used VB in a while, but this should give you the gist of it ;)):
Code: [Select]
Dim rom As New DataGridViewRow()
rom.Cells(0).Value = number
rom.Cells(1).Value = name
rom.Cells(2).Value = size
rom.Cells(3).Value = type
DataGridView.Rows.Add(rom)

EDIT: You're also re-declaring you're array each time you go through your loop. Unless you removed some code (or I'm not understanding your code right), that's completely redundant :S
« Last Edit: August 10, 2011, 11:55:31 pm by BlakPilar »