Hello all,
Basically I have a tabbed panel with 2 panels and a variable that controls which set of controls is shown by the tabs. If the user tries to move to an unauthorized tab I want that to be pretty much denied and reversed. The below code is pretty simple, am I misunderstanding this or is this a bug? Thanks!
Sub PanelChanged() Handles PanelChanged
If(panelMode=0) Then
Me.SelectedPanelIndex=0
Else
Me.SelectedPanelIndex=1
End
End Sub
In PanelChanged the panel has already been changed. So the stack overflow is no wonder. I would recommend a canvas based tab panel so that you can prohibit the panel change on your own.
I know the panel has already been changed but wouldn’t this just change it back? Or does changing the panel via “SelectedPanelIndex” also trigger the panelchanged event making an infinite loop?
Sub PanelChanged() Handles PanelChanged
If(panelMode=0) And Me.SelectedPanelIndex<>0 Then
Me.SelectedPanelIndex=0
ElseIf Me.SelectedPanelIndex<>1 Then
Me.SelectedPanelIndex=1
End
End Sub
On two of the three Desktops, that works. On the third it doesn’t. Can’t remember which is which just now, not at my desk, will look in my app later and post again.
On the third desktop I do something different to make it work.
OK turns out it is Linux that has the issue. So in my PanelChanged event I have, inter alia, this code:
if (me.SelectedPanelIndex=currentPanel) then Return
#if (TargetLinux=False) then
me.SelectedPanelIndex = currentPanel // Not Linux, just set the panel back to what it was
#EndIf
#if (TargetLinux=True) then // Linux, have to wait before reverting panel
Timer.CallLater (1, WeakAddressOf setPanelIndex)
#EndIf
.
And the setPanelIndex method is merely:
// Only used under Linux to reset the panel.
#if (TargetLinux=True) then
PrefsTab.SelectedPanelIndex = currentPanel
#EndIf