|
-
Oct 31st, 2007, 10:57 AM
#1
Thread Starter
KING BODWAD XXI
-
Oct 31st, 2007, 01:16 PM
#2
Re: Listbox confusion
not sure what you mean by blank out.. if they rows are there but have blank strings as their text? or they don't appear at all..
2 things in your code that stand out right away are:
1) you should be using integer instead of long, the fact that you are using long makes me think you have option strict off, which you should really turn on.
2) your looping from 1 to ubound(array), array indexes start at 0, so unless you are skipping the first element of the sites array on purpose, your code is skipping that element.
Now these 2 things don't specifically explain your issue per-say, I can tell you this code works fine:
Code:
Public Structure SiteInfo
Dim Name As String
Dim Town As String
Dim Postcode As String
Dim serial As String
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Sites(3) As SiteInfo
With Sites(0)
.Name = "Test 1"
.Postcode = "00001"
.Town = "Town 1"
.serial = "001"
End With
With Sites(1)
.Name = "Test 2"
.Postcode = "00002"
.Town = "Town 2"
.serial = "002"
End With
With Sites(2)
.Name = "Test 3"
.Postcode = "00003"
.Town = "Town 3"
.serial = "003"
End With
With Sites(3)
.Name = "Test 4"
.Postcode = "00004"
.Town = "Town 4"
.serial = "004"
End With
Dim I As Integer
Dim ListVI As ListViewItem
With lvDetails
'Clear All
.Clear()
.Columns.Add("Site", 200, HorizontalAlignment.Left)
.Columns.Add("Town", 200, HorizontalAlignment.Left)
.Columns.Add("PostCode", 100, HorizontalAlignment.Left)
.Columns.Add("Serial", 100, HorizontalAlignment.Left)
'Create Column Details
For I = 0 To Sites.GetUpperBound(0)
'Clear Items
ListVI = New ListViewItem(Sites(I).Name)
ListVI.SubItems.Add(Sites(I).Town)
ListVI.SubItems.Add(Sites(I).Postcode)
ListVI.SubItems.Add(Sites(I).serial)
.Items.Add(ListVI)
Next I
End With
End Sub
-
Oct 31st, 2007, 03:57 PM
#3
Frenzied Member
Re: Listbox confusion
I have just been thu the listview learning curve mt self
this may also help
http://www.vbforums.com/showthread.php?t=493151
-
Nov 1st, 2007, 02:53 AM
#4
Thread Starter
KING BODWAD XXI
Re: Listbox confusion
*BANG*
*BANG*
*BANG*
Although my head hurts after that I feel I deserve it. I was being a right retard and setting element 1 in my test array twice instead of setting number 2.
I feel it is going to be one of those days
It works now lol. Thanks for the help and I will change that variable to integer. Am I right in saying integers in .net are now the equivilent of longs in vb6?
-
Nov 1st, 2007, 08:48 AM
#5
Re: Listbox confusion
yes you are correct in saying that.
VB6 integer = .NET short (16 bit int)
VB6 long = .NET integer (32 bit int)
-
Nov 1st, 2007, 10:14 AM
#6
Thread Starter
KING BODWAD XXI
Re: [RESOLVED] Listbox confusion
Cheers
only just moving over and its very confusing when they change things like that. :s
-
Nov 1st, 2007, 10:55 AM
#7
Re: [RESOLVED] Listbox confusion
I hear ya, but you pick it all up pretty fast.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|