Calendar?

pdabasic

Active Member
Licensed User
Hy!

I would like to use the calendar control and the "GetControls" function.
When I Drop Down The calendar control, it is adding a new control, but it doesn't defined...
Why? :sign0085:

Here is a sample with my problem:
 

Attachments

  • Calendar.sbp
    758 bytes · Views: 239

agraham

Expert
Licensed User
Longtime User
BringToFront is a method not a property so you don't assign it, the IDE doesn't mind but the compiler will complain.

Calendar(cont(len-1)).BringToFront

Note that using BringToFront alters the position of the controls in the array so that a control will not stay at the same index as you are assuming. This is the real reson for the problem you are having. However dropping down the Calendar does indeed seem to add a non-existent control with a blank name to the list of controls.
 

pdabasic

Active Member
Licensed User
I know the BringToFront method it was just a fault on my sample!
My original app I try to set all control property ".Top=0" but after I use the calendar control the sub doesn't work because it find an 'undeclared object' (or I don't know how can I say it English because my message is in Hungarian)

So my Question:
How can I use my sub with Calendar Control?
 

agraham

Expert
Licensed User
Longtime User
How can I use my sub with Calendar Control?
I tried to say that you can't. Your Sub assumes that the Calendar is always at the same position in the arrays of control names and this is not so if you use BringToFront.

Why not just use Calendar1.BringToFront.
 

pdabasic

Active Member
Licensed User
I think we misunderstand eachother :)
Only what I want that my app works after I set the Calendar change value
Here is my code what makes the alert after I change the date!
How can I reedit it or what I have to put inside of code, to make it without alert!
How can I skip the +control in the array?

B4X:
controls()=GetControls(contParent)
For i=0 To ArrayLen(controls())-1
controlsPos(i)=Control(controls(i)).Top
Next
 

agraham

Expert
Licensed User
Longtime User
You could try checking that the control name is not an empty string. Don't assume that the position of a control in the array is always the same.
B4X:
controls()=GetControls(contParent)
For i=0 To ArrayLen(controls())-1
  If controls(i) <> "" Then 
    controlsPos(i)=Control(controls(i)).Top
  End If
Next
 

pdabasic

Active Member
Licensed User
You could try checking that the control name is not an empty string. Don't assume that the position of a control in the array is always the same.
B4X:
controls()=GetControls(contParent)
For i=0 To ArrayLen(controls())-1
  If controls(i) <> "" Then 
    controlsPos(i)=Control(controls(i)).Top
  End If
Next

I try it!
Thank you Agraham again
 
Top