In Visual Basic.Net, A combobox class has an Items property. And it is an indexed property. We can get the items by passing an index as parameter. On the same time, this Items property has some fields and methods like "Add", "Count", "Clear" etc.
My question is, how to do it in FreeBasic ?. I have a combobox type and it contains an Items type. So members like Add, Clear are working very well. I can use the dot notation like this --> "ComboBox.Items.Add("Item1").
But when it comes to an indexed property, compiler gives error messages . And here is the model i am working now. It is not the actual code. But if this prototype worked, i can adapt this into my code.
Code: Select all
Type ItemsClass Extends Object
sList(Any) As String
Declare Property Count() As Integer
Declare Sub Add(Byval Item As String)
Declare Sub Clear()
Declare Sub RemoveAt(Byval Index As Integer)
Declare Sub Insert(Byval Item As String, Byval Index As Integer)
Property ItemsClass.Count() As Integer
Sub ItemsClass.Add(Byval Item As String)
ArrayAdd(sList, Item) ' ArrayAdd is a simple macro. It just redim and put things into array.
Items As ItemsClass
Declare Property Items(Byval Index As Integer) As String
Property ComboBox.Items(Byval Index As Integer) As String
Dim cmb As ComboBox
About the error messages -
1. Property declaration of Items in Combobox - Duplication definition. - (Do i need an Overload clause ?)
I think i am confusing compiler with giving same names for a property and a member type.