Create a PopupMenu ControlSet

Hi all!

Always I used Controlset in RadioButtons, Because its more practical to know which option you used by making a Select Case me.index.

But Now I wonder if its possible to do a ControlSet of a PopupMenu.

For This:

  1. I make three PopUpMenu from the IDE
  2. Select this three PopUpMenus
  3. Change the name to “PopFechaInicial”

Then Xojo Ask me that If I want to make a new ControlSet, so then I answer “Yes”

But Now I need to know how can I add different rows to each PopupMenu of the Controlset.

Thanks

[quote=257683:@Gerardo García]Hi all!

Always I used Controlset in RadioButtons, Because its more practical to know which option you used by making a Select Case me.index.

But Now I wonder if its possible to do a ControlSet of a PopupMenu.

For This:

  1. I make three PopUpMenu from the IDE
  2. Select this three PopUpMenus
  3. Change the name to “PopFechaInicial”

Then Xojo Ask me that If I want to make a new ControlSet, so then I answer “Yes”

But Now I need to know how can I add different rows to each PopupMenu of the Controlset.

Thanks[/quote]
I answer Myself, I tried to use Select Case me.index and it works:

[code] Select Case me.index

Case 0
me.addrow(“caso 0”)
me.ListIndex = 0

Case 1
me.addrow(“caso 1”)
me.ListIndex = 0

Case 2
me.addrow(“caso 2”)
me.ListIndex = 0

End Select[/code]

Just a couple of suggestions:

  1. me.Index is not necessary. Just use index which is passed to the event
  2. put the line me.listIndex = 0 ONCE after the End Select statement

[quote=257688:@Roger Clary]Just a couple of suggestions:

  1. me.Index is not necessary. Just use index which is passed to the event
  2. put the line me.listIndex = 0 ONCE after the End Select statement[/quote]
    Perfect!. I making a Date Selector with a Controlset of three PopUpMenus, thats what i Have at this time:

[code] Select Case index

Case 0
For i as Integer = 2016 DownTo 2011
me.addrow(str(i))
Next i

Case 1
For i as double = 12 Downto 1
me.addrow(Format(i,“00”))
Next i

Case 2
me.addrow(“caso 2”)

End Select
me.ListIndex = 0[/code]

At others times I do this For Analyze the popUpMenu(1), when the Listindex = 10 (february) using an If, to determine to Add only 29 Rows in case of February, Else add 31 Rows. But Now with the ControlSet I dunno what to do, thats the code that previously used, in Change Event of Month’s PopUpMenu (I hope to be clare in my explanation):

[code] If me.ListIndex = 1 Then
popDia.DeleteAllRows
For i As double = 1 to 29
popDia.AddRow(Format(i,“00”))
Next i

Else
popDia.DeleteAllRows
For i As double = 1 to 31
popDia.AddRow(Format(i,“00”))
Next i

End If[/code]

For adapt it to this Situation I planned this, but shows me a Syntax Error:

[code] Select Case index

Case 1
If me.Listindex = 10 Then
'me(2).AddRow(“casa”)
Else

End If

End Select[/code]

And my other question is How can I mix the three selected values to join it on a single value to show it on a message or pass it to a Variable.
:frowning:

[quote=257700:@Gerardo García]And my other question is How can I mix the three selected values to join it on a single value to show it on a message or pass it to a Variable.
:([/quote]
I see it on a Action Button: Msgbox popFechaInicial(0).text + “/” + popFechaInicial(1).text + “/” + popFechaInicial(2).text

[quote=257696:@Gerardo García]Perfect!. I making a Date Selector with a Controlset of three PopUpMenus, thats what i Have at this time:

[code] Select Case index

Case 0
For i as Integer = 2016 DownTo 2011
me.addrow(str(i))
Next i

Case 1
For i as double = 12 Downto 1
me.addrow(Format(i,“00”))
Next i

Case 2
me.addrow(“caso 2”)

End Select
me.ListIndex = 0[/code]

At others times I do this For Analyze the popUpMenu(1), when the Listindex = 10 (february) using an If, to determine to Add only 29 Rows in case of February, Else add 31 Rows. But Now with the ControlSet I dunno what to do, thats the code that previously used, in Change Event of Month’s PopUpMenu (I hope to be clare in my explanation):

[code] If me.ListIndex = 1 Then
popDia.DeleteAllRows
For i As double = 1 to 29
popDia.AddRow(Format(i,“00”))
Next i

Else
popDia.DeleteAllRows
For i As double = 1 to 31
popDia.AddRow(Format(i,“00”))
Next i

End If[/code]

For adapt it to this Situation I planned this, but shows me a Syntax Error:

[code] Select Case index

Case 1
If me.Listindex = 10 Then
'me(2).AddRow(“casa”)
Else

End If

End Select[/code][/quote]
Woooooohooooooo!!!.

I solved at this way:

on Change Event of my ControlSet:

[code] Select Case index

Case 1

If me.Listindex = 10 Then
  popFechaInicial(2).DeleteAllRows
  For i as Double = 29 Downto 1
    popFechaInicial(2).AddRow(Format(i,"00"))
  Next i
Else
  popFechaInicial(2).DeleteAllRows
  For i as Double = 31 Downto 1
    popFechaInicial(2).AddRow(Format(i,"00"))
  Next i
  
  
End If
popFechaInicial(2).ListIndex = 0

End Select[/code]

Why do this ?
It makes your code more complicated and relies on “indexes” to get different behaviour
Thats what subclasses are for

Just for instance the IDE does not use ONE control set that I can think of
When we need different behaviour we make a subclass & put the behaviour in there