Global Navigation Bar

MapInfo Products Knowledge Base


Product: MapBasic
Version: 4.x\5.x\6.x
Platform: Win9x\NT\2000
Category: Dialog Boxes

Summary:
Creating multi-column radio buttons.

Question:
Is it possible to create multi-column radio buttons (a single group of buttons not arranged in a single vertical column)? The standard radio-group control does not support multiple columns. Sometimes it is necessary to be able to select from multiple columns of options, due to dialog box size constraints or design limitations.

Answer:
In some cases it may be appropriate to work around this problem by choosing an item from a drop-down list instead. Otherwise, it is possible (though clunky) to build radio-button functionality out of checkboxes, which of course can be placed anywhere in a dialog box. Here is some sample code for a simple three-checkbox-radio-button dialog box. The .MB file is attached, code listing follows.

testrad.MB

If it is desired to be able to read the current selection from a single global variable (analogous to the way a radio group works). it would be necessary to 'dim ChkRadioResult as integer' at the top, then set ChkRadioResult appropriately in each of the three subroutines chk1, chk2, chk3.

Include "MAPBASIC.DEF"
dim c1, c2, c3 as Logical
Declare Sub Main
Declare Sub chk1
Declare Sub chk2
Declare Sub chk3
Sub Main
Dialog
Title "TestChkRadio"
Width 250 Height 20
Control CheckBox
Position 10,10 Width 66
ID 1
Title "chk1"
Value FALSE
Calling chk1
into c1

Control CheckBox
Position 76,10 Width 66
ID 2
Title "chk2"
Value FALSE
Calling chk2
into c2

Control CheckBox
Position 142,10 Width 66
ID 3
Title "chk3"
Value FALSE
Calling chk3
into c3
End Sub

Sub chk1
Alter Control 1 Value TRUE
Alter Control 2 Value FALSE
Alter Control 3 Value FALSE
End Sub

Sub chk2
Alter Control 1 Value FALSE
Alter Control 2 Value TRUE
Alter Control 3 Value FALSE
End Sub

Sub chk3
Alter Control 1 Value FALSE
Alter Control 2 Value FALSE
Alter Control 3 Value TRUE
End Sub

Last Modified: 12/06/2000 12:30:03 PM
Global Navigation Bar