Forum: VB.NET |
Thema:
AW: AW: AW: AW: AW: AW: Clear in Klasse |
Von:
M Merlin (
20.03.2007 10:53) |
Also... irgendwie ist da der Wurm drin.....
Deine Function Add funktioniert nicht.... -> Me.Add(o) Falsche Anzahl Parameter...
Habe dann die Class so geändert:
Public Class ArrayDistributorList
Inherits ListBase(Of Distributors)
Public Department As String
Public ID As Long
Public Shadows Function Add(ByVal d As Distributor) As Distributor
Me.Add(d)
Return d
End Function
Public Shadows Function Add(ByVal ID As Long, ByVal Department As String) As Distributor
Dim d As New Distributor
With d
.ID = ID
.Department = Department
End With
Me.Add(d)
Return d
End Function
End Class
Wenn ich jetzt die mit Add einen Distributor hinzufüge komme ich in eine Enlosschleife..... aber ohne " Public Shadows Function Add(ByVal d As Distributor) As Distributor" bekomme ich immer noch einen Fehler...
Hier mal meine Klassen Distributor und Distributors vielleicht heilft das etwas zur Erklärung:
Public Class Distributor
#Region "StandardProperties"
Private mvarIDDistributor As Long
Private mvarName As String
Private mvarFirstName As String
Private mvarDepartmet As String
Private mvarShortName As String
Private mvareMail As String
Private mvarPrintSequence As Integer
Private mvarIDArrival As Long
Public Property ID() As Long
Get
Return mvarIDDistributor
End Get
Set(ByVal Value As Long)
mvarIDDistributor = Value
End Set
End Property
Public Property Name() As String
Get
Return mvarName
End Get
Set(ByVal Value As String)
mvarName = Value
End Set
End Property
Public Property FirstName() As String
Get
Return mvarFirstName
End Get
Set(ByVal Value As String)
mvarFirstName = Value
End Set
End Property
Public Property Department() As String
Get
Return mvarDepartmet
End Get
Set(ByVal Value As String)
mvarDepartmet = Value
End Set
End Property
Public Property ShortName() As String
Get
Return mvarShortName
End Get
Set(ByVal Value As String)
mvarShortName = Value
End Set
End Property
Public Property eMailAdress() As String
Get
Return mvareMail
End Get
Set(ByVal Value As String)
mvareMail = Value
End Set
End Property
Public Property PrintSequence() As Integer
Get
Return mvarPrintSequence
End Get
Set(ByVal Value As Integer)
mvarPrintSequence = Value
End Set
End Property
Public Property Arrival() As Long
Get
Return mvarIDArrival
End Get
Set(ByVal Value As Long)
mvarIDArrival = Value
End Set
End Property
#End Region
#Region "Eigendefinierte Eigenschaften"
Public Overridable Function FullName(ByVal Trennzeichen As String) As String
Dim Dummy As String
If Trennzeichen = String.Empty Then Trennzeichen = Komma & " "
Dummy = mvarName & " " & Trennzeichen & " " & mvarFirstName
Return Dummy
End Function
#End Region
#Region "Methoden"
Public Overrides Function ToString() As String
Return FullName(Komma & " ")
End Function
#End Region
End Class
Public Class Distributors
Inherits CollectionBase
Public Function Add(ByVal d As Distributor) As Distributor
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dName As String, ByVal dFirstName As String) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Name = dName
.FirstName = dFirstName
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dName As String, ByVal dFirstName As String, ByVal dDepartment As String, ByVal dShortName As String) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Name = dName
.FirstName = dFirstName
.Department = dDepartment
.ShortName = dShortName
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dName As String, ByVal dFirstName As String, ByVal dDepartment As String, ByVal dShortName As String, ByVal deMail As String) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Name = dName
.FirstName = dFirstName
.Department = dDepartment
.ShortName = dShortName
.eMailAdress = deMail
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dName As String, ByVal dFirstName As String, ByVal deMail As String) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Name = dName
.FirstName = dFirstName
.eMailAdress = deMail
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dName As String, ByVal dFirstName As String, ByVal deMail As String, ByVal dPrintSequence As Integer) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Name = dName
.FirstName = dFirstName
.eMailAdress = deMail
.PrintSequence = dPrintSequence
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dArrival As Long, ByVal dPrintSequence As Integer) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Arrival = dArrival
.PrintSequence = dPrintSequence
End With
List.Add(d)
Return d
End Function
Public Function Add(ByVal dID As Long, ByVal dDepartment As String) As Distributor
Dim d As New Distributor
With d
.ID = dID
.Department = dDepartment
End With
List.Add(d)
Return d
End Function
Default Public ReadOnly Property Item(ByVal Index As Integer) As Distributor
'Muss gesetzt werden um in der Form die Liste per Item zu füllen
Get
Return CType(List.Item(Index), Distributor)
End Get
End Property
End Class
Betreff |
Von |
Datum |
|
|
AW: Clear in Klasse
Also wieso gibt es zwei Listen mit Objekten für die selbe Aufgabe (Distributor und ArrayDistributorList) <br><br>Was möchtest du genau anstellen? Eine Liste mit Listen erstellen?<br><br>Möchtest du beim... |
|
|
|
|
|
Bernhard
Grojer
|
20.03.2007 11:50 |
|
|
AW: AW: Clear in Klasse
OK. Jetzt funktioniert es auch....<br><br>Warum gibt es zwei Listen ?<br><br>Genau das ist der Clou: Ich benutzte aus den Klassen Distributor/Distributors eine Liste mit den "Verteilern" zum Einlesen,... |
|
|
|
|
|
M
Merlin
|
20.03.2007 12:16 |
|
|
AW: AW: AW: Clear in Klasse
Du kannst auch die Distributors Liste direkt an die Combobox binden. Sie implementiert alle benötigten Interfaces!<br><br>comboBox1.ValueMember = "ID"<br>comboBox1.DisplayMember =... |
|
|
|
|
|
Bernhard
Grojer
|
20.03.2007 14:29 |
|
|
AW: AW: AW: AW: Clear in Klasse
Schon richtig.... aber....<br>Ich übergebe Werte aus der ComboBox in die ListBox ( beim Click der ComboBox ).<br>In der ComboBox habe ich als ValueMember "ID" als DisplayMember "FullName" der setzt sich... |
|
|
|
|
|
M
Merlin
|
20.03.2007 17:08 |
|
|
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!