hi zusammen, komme einfach nicht weiter:
http://msdn.microsoft.com/library/deu/default.asp?url=/library/DEU/cpref/html/frlrfsystemwindowsformslistcontrolclassdatasourcetopic.asp
da ist ein Beipiel:
[Visual Basic]
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Collections
Public Class USState
Private myShortName As String
Private myLongName As String
Public Sub New(ByVal strlongName As String, ByVal strShortName As String)
MyBase.New()
Me.myShortName = strShortName
Me.myLongName = strLongName
End Sub
Public ReadOnly Property ShortName() As String
Get
Return myShortName
End Get
End Property
Public ReadOnly Property LongName() As String
Get
Return myLongName
End Get
End Property
Public Overrides Function ToString() As String
Return Me.ShortName & " - " & Me.LongName
End Function
End Class
Public Class ListBoxSample3
Inherits Form
Friend WithEvents ListBox1 As ListBox = New ListBox()
Dim textBox1 As TextBox = New TextBox()
<System.STAThreadAttribute()> _
Public Shared Sub Main()
System.Windows.Forms.Application.Run(New ListBoxSample3())
End Sub
Public Sub New()
Me.AutoScaleBaseSize = New Size(5, 13)
Me.ClientSize = New Size(292, 181)
Me.Text = "ListBox Sample3"
ListBox1.Location = New Point(24, 16)
ListBox1.Name = "ListBox1"
ListBox1.Size = New Size(232, 130)
textBox1.Location = New Point(24, 160)
textBox1.Name = "textBox1"
textBox1.Size = New Size(40, 24)
Me.Controls.AddRange(New Control() {ListBox1, textBox1})
' Populates the list box using DataSource.
' DisplayMember is used to display just the long name of each state.
Dim USStates As New ArrayList()
USStates.Add(New USState("Washington", "WA"))
USStates.Add(New USState("West Virginia", "WV"))
USStates.Add(New USState("Wisconsin", "WI"))
USStates.Add(New USState("Wyoming", "WY"))
ListBox1.DataSource = USStates
ListBox1.DisplayMember = "LongName"
ListBox1.ValueMember = "ShortName"
End Sub
Private Sub InitializeComponent()
End Sub
Private Sub ListBox1_SelectedValueChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If ListBox1.SelectedIndex <> -1 Then
textBox1.Text = ListBox1.SelectedValue
End If
End Sub
End Class wennch das laufen lassen will kommt folgender fehler: Private Sub ListBox1_SelectedValueChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged
If ListBox1.SelectedIndex <> -1 Then
textBox1.Text = ListBox1.SelectedValue
End If
End Sub FEHLER::::Fehler beim Erstellen des Formulars. Weitere Informationen finden Sie in Exception.InnerException. Fehler: Ungültige Konvertierung von Typ USState in Typ String..
keine Ahnung was ich da falsch mache ??
kannmiir mal jemand sage wie ich diese beispiel umsetze
vb. 2005 starten ......neue windowsanwendung ?
das ist denk eine klasse
form und listbox werden erstellt ?
da mal die schritte ...dass ich solche dinger die mit class ... beginnen umsetzen kann
danke
gruss roland_k
blutiger anf?nger
ich weiss was ich will
aber eben nicht wie es geht  |