Radio button on the fly (OpenInsight 32-bit Specific)
At 29 SEP 2008 10:42:58AM Simon G Wilmot wrote:
Hi all,
Has anyone created a radio button control on the fly, or adapted a radio button control depending on certain conditions - ie no of buttons, default selection, value and label …
I am just after a code snippet to set me on my way.
TIA,
Simon
At 29 SEP 2008 07:24PM Colin Rule wrote:
Simon
The tricky bit with radio buttons is that you have properties for the group of radio buttons, and also for individual items.
I have a radio button on most screens called DEVICE, which is associated with by Print button, and has 'Printer, Screen, Excel, Export' as the 4 options. (being phased out in favour of menus).
As this is at the bottom of the screen, I wanted to have 2x2, rather than 4 vertical or 4 horizontal.
I use the normal SIZE property on the group to resize the control,eg:
CALL SET_PROPERTY(@WINDOW:".":DEV,"SIZE",DEV_SIZE)
This is because changing the text properties of radio buttons does not automatically increase their size, which is set by Form Designer, so if you change the text you have to change the size in code.
Then I calculate the size of the individual radio button, and position it, eg:
CALL SET_PROPERTY(@WINDOW:".":DEV:".EXPORT","SIZE",DEV_SIZE)
Note that the control name is Window.Group.Item
The last part is the original name as provided in Form Designer.
Hope this helps.
Colin
At 30 SEP 2008 06:28AM Simon G Wilmot wrote:
Hi Colin,
Thanks for that, I had already sorted what I wanted to do, but hadn't thought of the '2x2' scenario - that may come in handy later.
Thanks,
Simon
At 30 SEP 2008 06:55AM Simon G Wilmot wrote:
However … it isn't working quite as I wanted.
What I have done is to have a radio group with 10 buttons, and on create of the window then to manipulate the texts/labels/visible/size properties of the various bits.
That works fine.
However, when I make some changes to an edit-table on the window, I want those changes to be reflected in the radio group. A straight swap of labels/values is no problem, but when I want to increase the group size displayed (currently from 3 to 4), then it doesn't increase the size.
Is there a little trick I am missing here ??
Regards,
Simon
At 30 SEP 2008 07:12AM Colin Rule wrote:
You will need to size the control with the maximum number of items that you might need.
You can then make some invisible on the create event, and then change the text property and make them visible when you need them.
Colin
At 30 SEP 2008 07:55AM Simon G Wilmot wrote:
Hi Colin,
Actually I can re-size it as needed, I just had some over-zealous invisible settings that I forgot to undo as I went along.
Thanks,
Simon