Article Preview
Buy Now
COLUMN
Column
Issue: 15.4 (July/August 2017)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 6,865
Starting Page Number: 77
Article Number: 15408
Resource File(s):
project15408.zip Updated: 2017-07-02 23:30:00
Related Link(s): None
Excerpt of article text...
Someone on the forums recently asked about how to initialize a Listbox without using the
InitialValue
setting, which you have to set within the IDE. Sometimes you want a Listbox (or another control) to have an initial value, but the data you want to include might be dynamic and not available when the app is being created.(A perfect example is reloading a user's previous values into a control upon launch so that everything is the way the user left it when they last quit the app.)
The way I have solved this problem is via one of Xojo's most powerful and under-appreciated techniques: class extensions.
I've written about class extensions before, but they're worth a revisit. Extensions allow you to "extend" a class
without creating a subclass .Creating a subclass isn't difficult, of course, but it's extra work and it requires that all the instances of that class in your project be changed to the subclass type. Class extensions are cool because they let you add features to the built-in classes without having to change the rest of your program.
Initializing
...End of Excerpt. Please purchase the magazine to read the full article.