Results 1 to 3 of 3

Thread: displaying tables

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Phoenix
    Posts
    3

    displaying tables

    I am a new user of vb.net and all I want to do is display a simple 2 dimensional array of numbers on a form in a scrollable table. 2 columns by 60,000 rows. I tried putting a grid control on the from, but I cannot figure out how to load it. Then I tried declaring a datatable, but even that seems like overkill for such a simple structure. Is there an easy way to do this? I could use a code snippit to get started. Thanks for your help.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    I wrote a little stupid function that adds it to a listview.... remember that both dementions of the array must have equal lengths, otherwise it causes an error (bad coding!!!)

    VB Code:
    1. ' Gets a 2D array of integers
    2.     Private Sub ArrayToLvw(ByRef arr As Integer(,), ByRef lvw As ListView)
    3.         lvw.Columns.Clear()
    4.         lvw.View = View.Details
    5.         lvw.Columns.Add("Column1", 100, HorizontalAlignment.Center)
    6.         lvw.Columns.Add("Column2", 100, HorizontalAlignment.Center)
    7.         lvw.Items.Clear()
    8.  
    9.  
    10.         Dim i As Integer
    11.         Dim li As ListViewItem
    12.  
    13.         For i = 0 To arr.GetUpperBound(0)
    14.             li = lvw.Items.Add(arr(i, 0).ToString)
    15.             li.SubItems.Add(arr(i, 1).ToString)
    16.         Next
    17.     End Sub

    HTH
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    I've been doing something pretty much the same with ListViews as what Mr.Polite shows.

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