我絕對新VB.NET,我做了一些VBS很久以前。vb.net數組列表將不會加載
現在我想做一個MVP還挺系統,我試圖定義並加載一個陣列,通過該系統。然後讀出它,它應該填充一個ListView1對象。
誰能閃耀爲什麼它不填充一些輕。我知道他們設置正確,因爲控制檯告訴我它已經設置好了。
我知道樣品將與同一項目(每週要準確)填寫我每次添加一個項目的時間,但是這不是問題的關鍵。
另外,是否有可能定義數組沒有索引,我的意思是現在我與(6)設置,以便它爲字符串6個塊,但我想更加靈活。
有沒有辦法像在PHP例如 $項目[ 「名字」] $項目[ 「姓氏」] ...
感謝您的時間和精力! :-)
ClientlistItem.vb(實際的項目的定義)
Public Class ClientlistItem
Private entry(6) As String
Public Sub New(ByVal iEntry() As String)
entry(0) = iEntry(0)
entry(1) = iEntry(1)
entry(2) = iEntry(2)
entry(3) = iEntry(3)
entry(4) = iEntry(4)
entry(5) = iEntry(5)
End Sub
End Class
ClientList.vb(該模型因爲它是)
進口System.Collections.Generic
Public Class Clientlist
Public Event ClientlistChanged()
Private mItems As List(Of ClientlistItem) = New List(Of ClientlistItem)
Public ReadOnly Property Items() As List(Of ClientlistItem)
Get
Return mItems
End Get
End Property
Public Sub AddItem(ByRef iEntry() As String)
Console.WriteLine(iEntry(0))
Dim item As ClientlistItem = New ClientlistItem(iEntry)
mItems.Add(item)
RaiseEvent ClientlistChanged()
End Sub
End Class
ClientlistPresenter.vb(主持人)
Public Class ClientlistPresenter
Private iEntry() As String
Private mClientlistModel As Clientlist
Private mClientlistView As ClientlistView
Public Sub New(ByRef view As ClientlistView)
mClientlistModel = New Clientlist
mClientlistView = view
mClientlistView.Init(mClientlistModel, Me)
End Sub
Public Sub AddItem(ByVal iEntry() As String)
mClientlistModel.AddItem(iEntry)
End Sub
End Class
ClientlistView.vb(視圖..這有我想填補的ListView)
Imports System.Windows.Forms
Public Class ClientlistView
Private mClientlistPresenter As ClientlistPresenter
Private WithEvents mClientlistModel As Clientlist
Private Sub OrderView_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mClientlistPresenter = New ClientlistPresenter(Me)
End Sub
Private Sub Orderview_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Resize
Dim fWidth As Integer = Me.Width
Dim fHeight As Integer = Me.Height
ListView1.Bounds = New Rectangle(New Point(0, 25), New Size(fWidth, fHeight))
End Sub
Public Sub Init(ByRef model As Clientlist, ByRef presenter As ClientlistPresenter)
mClientlistPresenter = presenter
mClientlistModel = model
' Set the view to show details.
listView1.View = View.Details
' Allow the user to rearrange columns.
listView1.AllowColumnReorder = True
' Display check boxes.
listView1.CheckBoxes = True
' Select the item and subitems when selection is made.
listView1.FullRowSelect = True
' Display grid lines.
listView1.GridLines = True
' Sort the items in the list in ascending order.
listView1.Sorting = SortOrder.Ascending
ListView1.Columns.Add("#", 40, HorizontalAlignment.Left)
ListView1.Columns.Add("Wholename", 140, HorizontalAlignment.Left)
ListView1.Columns.Add("Date of birth", 80, HorizontalAlignment.Left)
listView1.Columns.Add("Country of birth", -2, HorizontalAlignment.Center)
' Add the ListView to the control collection.
Me.Controls.Add(listView1)
End Sub
Private Sub ClientlistChanged() Handles mClientlistModel.ClientlistChanged
ListView1.Items.Clear()
Dim i As Object
For Each i In mClientlistModel.Items()
Next
End Sub
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim week(6) As String
week(0) = "Sunday"
week(1) = "Monday"
week(2) = "Tuesday"
week(3) = "Wednesday"
week(4) = "Thursday"
week(5) = "Friday"
week(6) = "Saturday"
mClientlistPresenter.AddItem(week)
End Sub
End Class
在你的代碼你是哪裏試圖精確地填充ListView? – 2012-02-24 14:01:23