E
Edgardo
Hi, i am having a little problem with a combobox that i set his datasource
property to a collection, but doesn populate its items, the strange thing is
that i do the same thing on a datagrid and it works fine.
Take a look:
Public Class Account
Public Sub New(ByVal txtname As String, ByVal txtamount As Double)
name = txtname
amount = txtamount
End Sub
End Class
****************************************
Dim Accounts As New Collection()
Dim NewAccount As New Account("numer1", 1000)
Accounts .Add(NewAccount , 1)
Dim AnotherAccount As New Account("numer2", 2000)
Accounts .Add(AnotherAccount , 2)
*******************************************
Me.ComboBox.DataSource = Nothing
Me.ComboBox.DataSource = Accounts
Me.ComboBox.DisplayMember = "Name"
Me.ComboBox.ValueMember = "Amount" -----Error
"An unhandled exeception of type 'System.InvalidCastException ocurred in
microsoft.visualbasic.dll
Cast from type 'Microsoft.VisualBasic.Collection' to type 'Object()' is not
valid'"
Any ideas?
why i can set the same datasource for a datagrid and the is no error
showing? am i manipulating wrong the collection?
Any suggestion will help.
Thanks for your time
property to a collection, but doesn populate its items, the strange thing is
that i do the same thing on a datagrid and it works fine.
Take a look:
Public Class Account
Public Sub New(ByVal txtname As String, ByVal txtamount As Double)
name = txtname
amount = txtamount
End Sub
End Class
****************************************
Dim Accounts As New Collection()
Dim NewAccount As New Account("numer1", 1000)
Accounts .Add(NewAccount , 1)
Dim AnotherAccount As New Account("numer2", 2000)
Accounts .Add(AnotherAccount , 2)
*******************************************
Me.ComboBox.DataSource = Nothing
Me.ComboBox.DataSource = Accounts
Me.ComboBox.DisplayMember = "Name"
Me.ComboBox.ValueMember = "Amount" -----Error
"An unhandled exeception of type 'System.InvalidCastException ocurred in
microsoft.visualbasic.dll
Cast from type 'Microsoft.VisualBasic.Collection' to type 'Object()' is not
valid'"
Any ideas?
why i can set the same datasource for a datagrid and the is no error
showing? am i manipulating wrong the collection?
Any suggestion will help.
Thanks for your time