CustomViewSpinner:How to do?

Theera

Expert
Licensed User
Longtime User
Hi all,
I'm studying about the custom view,I 've added the custom spinner in the example. But I couldn't finish my work. Please help me.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
Attached two modified versions.
CustomViewSpinner_1 code for Designer support only
CustomViewSpinner_2 code for Designer support and for adding the custom view by code.

Did you have a look at the last update of the User's Guide ?

Best regards.
 

Attachments

  • CustomViewSpinner_1.zip
    8.7 KB · Views: 196
  • CustomViewSpinner_2.zip
    8.8 KB · Views: 214
Upvote 0

Theera

Expert
Licensed User
Longtime User
Thank you,Klaus
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
My Wanted is

Hi Klaus,
In your example1 for give me,I'm sorry that I explained my wanted is not clearly. If I would like using customcboBox.selectedItem in main of program,I couldn't do it. I couldn't set cboBox.selectedItem=lbl.text in samplecbobox.bas ,because it warns that be "Read Only"
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
A Spinner doesn't allow to set SelectedItem, this property is read only.
If you want to define such a 'property' and set it you'd need to memorize all items of the Spinner in a list, modify the the selected item in the list, clear the spinner, and reload all the items from the list into the Spinner.
You find an explanation on how to add properties to a class in the User's Guide.

Best regards.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
A Spinner doesn't allow to set SelectedItem, this property is read only.

Hi Erel,
I'm not sure, Is this custom view feather useful? I think myself why do you give our use this "Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map)"? Why don't you give use "Public Sub DesignerCreateView(Base As Panel, cbobox As spinner, Props As Map)?,The second parameter is varied as follow the custom view,If I create the custom view as spinner. the lbl has not the method.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should also read carefully the User's Guide.
The purpose of Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map) is explained in chapter 10.6 Display a custom view in the Designer the roles of Base, lbl and Map too.
As explained in post #5, the SelectedItem property of a Spinner is read only you cannot set it !
If you want a settable SelectedItem property in your custom view you must add it in the code as explained in post #5.
How to add properties to a CustomView is explained in detail in the User's Guide chapter 10.5 Add properties to a class, concrete examples are in chapters 10.3 and 10.4.
Any property you want for your CustomView must be added in the Class code. The original properties of any view you add in the class are not directly accessible from outsides the class.

Best regards.
 
Last edited:
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi Erel,Klaus
@Erel, I'm sorry to said that my language is not translate to be the worst. I hope that the feater is nearly as ActiveX which be used in VB6.0 In VB6.0 has many objects for using. I think that B4A product is the best product in decade.
@Klaus,I'm not good at programing,I would you to show me example. I hope for kind of you.
 
Last edited:
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi Klaus,
I've read your UserGuide at 10.5 Page 155,I need to ask you the following lines below
B4X:
Code in the calling module :
       ltbTest.Max= MaxValue

I don't know that MaxValue and ltbTest.Max come from,Why does ltbTest know his the member?,ltbTest.Max is used always in Sub Activity_Resume or not? ,I should declare MaxVal this format
B4X:
    Private MaxVal as Int in Class Module or Public MaxVal as Int in Sub Globals?
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi Klaus,
I could do it already. Yahoo!,Thank you for help,Please answer post #12 too,I still not understand all.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Code in the calling module :
ltbTest.Max = MaxValue

MaxValue must be declared somewher Dim MaxValue As Int and set a value to it, you could also use: ltbTest.Max = 100

In the calling routine ltbTest.Max is known because in the class we have two routines setMax and getMax !
When you add in a Class a routine like setMyProperty and/or getMyProperty B4A adds MyProperty as a property to the custonview.

Best regards.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Many Thanks ,Klaus You help me learning more. I have some question about coding in Post#13,Why do not I have selectedData as property of customCboBox?,but I have both setselectedData and getselectedData instead of it. How should I do for this coding?
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
When you add these two routines in the Class module setSelectedData and getSelectedData you will see in the calling module the SelectedData property.
getSelectedData could look like this:
B4X:
Sub getSelectedData As Object
    Return cboBox.SelectedItem
End Sub
For setSelectedData it depends on what exactly you want to do.
B4X:
Sub setSelectedData(Value As Object)
    ' your code
End Sub
Best regards.
 
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi Klaus,
Excause me for my stupid, the coding #13 ,I have picture as below. I don't understand that you have tried to explain. Please to give me the full version of solved. I need to know about different between yours and mine. I couldn't see customcbobox.selectedData member as property.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I saw the problem with getSelectedData which was not normal, to correct it I deleted the line and wrote it again.

Attached you find an example on how it could be.

Best regards.
 

Attachments

  • CustomViewSpinner3.zip
    8.5 KB · Views: 185
Upvote 0

Theera

Expert
Licensed User
Longtime User
Hi Klaus,
I'm understand now. Thank you for kind of you again.
 
Upvote 0
Top