Tell me please, can you sort the Items in RadioGroup in some way, for example alphabetically (of course with non-violation of the index binding)?
With the development of the application, there are more and more elements, but I don’t really want to change the indexes every time a new element is added to the middle of the list.
|
1 answer
The index is just a sequence number in the list. It cannot be saved when re-sorting.
Option 1:
Save values to RadioGroup1.Items.AddObject('Мадрид', TObject(3)); and accordingly get your value from an Integer(RadioGroup1.Items.Objects[RadioGroup1.ItemIndex]) object Integer(RadioGroup1.Items.Objects[RadioGroup1.ItemIndex])
Option 2:
Store data separately, and use RadioGroup1 only to display it. When user actions with RadioGroup1, save changes to the data, and when data changes (for example, re-sorting), dynamically rebuild RadioGroup1.
|
RadioGroup1.Items.AddObject('Мадрид',TObject(3));and accordingly get your value from aninteger(RadioGroup1.Items.Objects[RadioGroup1.ItemIndex])objectinteger(RadioGroup1.Items.Objects[RadioGroup1.ItemIndex])- JVic