![]() ![]() Then, we just need this to create a new instance, making it visible on the Window: Dim newInstance as PushButton = new btClon Let’s indicate that we have used as cloning template Control a PushButton and that we have named it btClon. ![]() Once our cloning control is all set, it’s time to reveal all the code we will need in order to create new instances of the control at run time. Now, probably you will want to change the Visibility Property to False on this first cloning template control, so it will not be visible to the users of the app no matter the resizing of the containing Window. ![]() Once you have created the new Control Set, you will see that the first instance of the Control Set is assigned the index number 0 succesive instances will have their index increassed by one, both the ones you may add to the Window (not what we want to do in this case), and those created at runtime (what we want to do). Tip: If you change the name of the Control used to create a Control Set, then you will have to recreate the Control Set, so rename the template Control in the first place! Then, and with the control still selected, you just have to push on the attributes button (the one with the image of a gearwheel) on the Inspector, selecting the New Control Set option from the Member Of entry under the Control Set Section. All of the instances of the Control Set will share the same Event Handlers, so you will have to use the additional index argument, passed to the Event Handler, in order to identify over which instance are you handling.īut, how can we create one of these Control Set after all? Well, we just need to put any control we want to use as a clonation template on the Window, even if it is placed outside the visible limits of the Window itself.The Control Sets may seem like Arrays, because you will use an index to refer every instance from the same Control Set, but they are not.You cannot create Control Sets for Container Controls.You can use Control Sets on Desktop and Web projects (although web projects cannot use Control Sets to dynamically create controls at runtime).You can use this feature to dynamically create any kind of control based on the RectControl class.Yes, this is all about the Control Set!īefore we put our hands on it, let’s make some things clear about the Control Set: Admit it – this is one of those questions that, sooner or later, arise to every Xojo newcomer: How can I add new UI controls to the Window at runtime? And if you are considering this too, then the good news is that the answer is more simple than you probably expect… sitting right there on the Inspector under the Attributes tab. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |