New topic: Modifying properties of cloned object at runtime
<http://forums.realsoftware.com/viewtopic.php?t=29670> Page 1 of 1 [ 6 posts ] Previous topic | Next topic Author Message okinelin Post subject: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 4:31 am Joined: Fri Aug 21, 2009 3:00 am Posts: 3 Hi All, In my program, I create control buttons at runtime by cloning. I want to be able to change properties of individual cloned buttons at runtime. How can I do this? For example. If I have 2 bevel buttons created by cloning at runtime and I want to change the size of one of the cloned buttons when the window is re-sized, how can this be done? Thanks Top f Post subject: Re: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 8:09 am Joined: Sun Apr 30, 2006 8:25 am Posts: 319 bevelbutton1(1).Top=80 _________________ Using RB prof edition http://wxq.nl/ Top computerfreaker Post subject: Re: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 8:56 am Joined: Thu Mar 05, 2009 1:03 pm Posts: 1415 Location: USA You need to create a control array (create the first button in the IDE, and give it an index of 0), then you can add new controls to the array & modify their properties... Code:dim NewButton as PushButton NewButton = new MyPushButtonArray(0) //clone the button //and modify its properties NewButton.Top = 5 NewButton.Left = 2 NewButton.Caption = "Hello, world!" _________________ With great power comes great responsibility. Learn something new every day, and the rest will take care of itself. Life is a journey, not a destination. Enjoy the trip! Top okinelin Post subject: Re: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 9:37 am Joined: Fri Aug 21, 2009 3:00 am Posts: 3 Quote:bevelbutton1(1).Top=80 Thanks a lot. I was using the control variable name instead of the name of the cloned control. Top okinelin Post subject: Re: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 11:51 am Joined: Fri Aug 21, 2009 3:00 am Posts: 3 Quote:bevelbutton1(1).Top=80 The code above works well. However, when I use "For loop" to iterate, it doesn't work. Is it that this index does not accept variable? Top serd83 Post subject: Re: Modifying properties of cloned object at runtimePosted: Fri Aug 21, 2009 12:31 pm Joined: Thu Feb 22, 2007 7:08 pm Posts: 656 How does your for loop look? Code:for i as integer = 0 to lastcontrol-1 bevelbutton1(i).Top=80 next Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 6 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
