Var startX As Integer = If(Controls.Count = 0, 20, Controls(Controls.LastIndex).Left + cWidth + 20) Initial X and Y coordinates for the control instance Static cInitialName As String = "ControlName" Write the following snippet of code in the associated Code Editor for the Method: // Setting static values for the new Button instances Add a new Method setting the following values in the associated Inspector Panel: We are going to need some Methods in the BaseContainer, starting with the one responsible for adding new DesktopButton instances. Use the Inspector panel to change the following properties:Īdd a new property to the BaseContainer subclass in the Navigator (use the contextual menu for that), setting the following values in the Inspector panel:Ģ. Double click on the Container in the Library so it is added to the Navigator in the IDE. Open Xojo and create a new Desktop project. Plus we’ll make them adjust as the size of the Container changes like you see in this example below. In order to see how this works, this example creates a Desktop project that includes multiple DesktopButton instances at runtime while also removing them from the target DesktopContainer (calling the Close method on the instance to do that). These values are relative to the left/top corner of the target window/container, so a value of top = 0 and left = 0 means to add the control at the top/left corner of the target window itself. To make the new DesktopUIControl instance really visible in the target window or container, you’ll need to set some basic properties specifically the desired width and height values for the new instance control and also the left and top coordinate values where you expect the control to be added. The new AddControl method on DesktopWindow and DesktopContainer accepts any DesktopUIControl instance you want to add to a window or container. Continue reading and I will show you how! Instead of having to deal with control arrays, when you use Xojo 2021r3 or later you can call the new AddControl method on the DesktopWindow (or DesktopContainer) where you want to add the new control. The process of adding new controls to windows (or containers) at runtime has been greatly simplified.
0 Comments
Leave a Reply. |