paulthepaddy
Well-known member
Hi all, This is quit a long explantion i think :S to simplfy this down im going to mention things i THINK are important if you would like more information please let me know what you want to know
Background Info: i Have an application that deals with cars, the most cars it will deal with at once is 10.
i have 3 comboboxes and only really need 2 i think
1 combobox is in an area that is for viewing the details of the car. my plan is for the user to select the car form the combobox list and the car info will be passed into a few labels
another combobox is for deleteing a car incase the user makes a mistake
the 3rd combobox was used when i was using bindinglists and delegates for my application to know what car to work with.
What I Would Like If Possable :
Be able to create an object from my class without declairing it manually in my code and it being named accordanly eg car1, car2,car3 and so on. or have it being added to a list that can be bound to comboboxsHave The Same list Bound to 2 comboboxes eaching combobox calling a diffrent sub
My Code:
My 'Car Class'
The Sub that uses the car class
i was hoping to be able to do something like this
but My Main Issue at the moment is i dont know how to fill a combobox with a list of items i have tried the following
but usng this as a datasource for a combobox is giving an error
(operator = is not defined for types Object and BindingList(Of car)) something along those lines
i tried putting the viewcar sub inside the car class and using a CallByName but again i could add the object into the list for it to send to the sub.
i hope i have explained enough any other info i have missed just ask
Thanks for any help in advance
Background Info: i Have an application that deals with cars, the most cars it will deal with at once is 10.
i have 3 comboboxes and only really need 2 i think
1 combobox is in an area that is for viewing the details of the car. my plan is for the user to select the car form the combobox list and the car info will be passed into a few labels
another combobox is for deleteing a car incase the user makes a mistake
the 3rd combobox was used when i was using bindinglists and delegates for my application to know what car to work with.
What I Would Like If Possable :
Be able to create an object from my class without declairing it manually in my code and it being named accordanly eg car1, car2,car3 and so on. or have it being added to a list that can be bound to comboboxsHave The Same list Bound to 2 comboboxes eaching combobox calling a diffrent sub
My Code:
My 'Car Class'
VB.NET:
Public Class car
Public Property Name As String
Public Make As String
Public Model As String
Public Colour As String
Public Reg As String
Public damage() As String
Public Subtotal As short
Public Discount As byte
Public additional As byte
Public Total As short
Public finished As Boolean = False
End Class
The Sub that uses the car class
VB.NET:
Public Sub ViewCar(SelectCar As car)
Form_Invoice_Management.lbl_Car_Make.Text = SelectCar.Make
Form_Invoice_Management.lbl_Car_Model.Text = SelectCar.Model
Form_Invoice_Management.lbl_Car_Colour.Text = SelectCar.Colour
Form_Invoice_Management.lbl_Car_Reg.Text = SelectCar.Reg
Form_Invoice_Management.lbl_Subtotal.Text = SelectCar.Subtotal
For i = 0 To (SelectCar.damage.Count - 1)
Form_Invoice_Management.ListBox_car.Items.Add(SelectCar.damage(i))
Next
If SelectCar.Discount <> 0 Then
Form_Invoice_Management.lbl_Discount.Text = SelectCar.Discount
Form_Invoice_Management.lbl_Dis_add.Text = "Discount"
ElseIf SelectCar.additional <> 0 Then
Form_Invoice_Management.lbl_Discount.Text = SelectCar.additional
Form_Invoice_Management.lbl_Dis_add.Text = "Additional"
Else
Form_Invoice_Management.lbl_Dis_add.Text = "Discount"
End If
Form_Invoice_Management.lbl_Total.Text = SelectCar.Total
End Sub
VB.NET:
me.ViewCar(Combobox_Car_View.SelectedItem)
VB.NET:
Dim Carselect As BindingList(Of car) = New BindingList(Of car)
(operator = is not defined for types Object and BindingList(Of car)) something along those lines
i tried putting the viewcar sub inside the car class and using a CallByName but again i could add the object into the list for it to send to the sub.
i hope i have explained enough any other info i have missed just ask
Thanks for any help in advance