Adding dynamic Controls to DesktopTabPanel / DesktopPagePanel

This is a little curious. I have TabPanel1 with two Tabs (DesktopTabPanel) and a button (DesktopButton) in my window. In the Button1.Pressed event I have the following code:

Var ctrl As New DesktopButton

ctrl.Caption = "Hello"
ctrl.Width = 80
ctrl.Height = 20
ctrl.Left = 20
ctrl.Top = 20
ctrl.Visible = True

ctrl.Parent = TabPanel1
ctrl.PanelIndex = 1

Self.AddControl(ctrl)

The button is not placed inside the TabPanel (2nd Tab), but above it.

Does anyone have an idea how to make this work correctly?

may be set the control left and top to a global value, and not relative to the tabpanel topleft ?

Are you not adding the button to the window and not the tabpanel?

Tried this, no difference.

Since the control is created in code, it has to be added to the the Window via DesktopWindow.AddControl. You can’t add a control to another control.

add the control, and then only set the parent ?

And here we go. Thanks @Jean-Yves_Pochez

Var ctrl As New DesktopButton

ctrl.Caption = "Hello"
ctrl.Width = 80
ctrl.Height = 20
ctrl.Left = 45
ctrl.Top = 45
ctrl.Visible = True

Self.AddControl(ctrl)

ctrl.Parent = TabPanel1
ctrl.PanelIndex = 1

you could still file a bug report for this … this should also work as your first post ?

At the first look yes, but since the Button don’t exists until we call AddControl, I think this is the expected behaviour.