The Update Radio Button Demo is the perfect way to keep your data table up-to-date. Using Live Bindings, this demo cross-platform application automatically updates your in-memory data table whenever a radio button changes. With support for Android, iOS, macOS, Windows, and Linux, you can build a single code base that looks and feels great on any platform.
Download the full cross-platform radio button data binding source code on Github.
This demo is part of over 100 cross-platform demos with everything from camera demos to emoji demos and painting demos.
Table des matières
What is a radio button control in software development?
A radio button is a type of graphical user interface (GUI) element that allows the user to choose one option from a group of mutually exclusive options. The radio button control consists of a round button that can be selected or deselected. When the user selects an option, the button becomes “filled” or “checked.” Radio buttons are typically used when there are a limited number of choices to be made, such as choosing a gender or selecting a answer to a yes-or-no question. In software development, radio buttons are often used in preference over other types of GUI elements, such as checkboxes, because they take up less screen space and can be easier for the user to understand.
Screenshot
What does the data bound radio button demo source code look like?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Des classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.StorageBin, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs, Fmx.Bind.Editors, FMX.StdCtrls, FMX.Layouts, Data.Bind.Composants, Data.Bind.DBScope, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, FMX.Effects, FMX.Controls.Presentation; type TForm1 = classe(TForm) MaterialOxfordBlueSB: TStyleBook; ToolBar1: TToolBar; ShadowEffect4: TShadowEffect; Label1: TLabel; Label2: TLabel; <strong> FDMemTable1: TFDMemTable; BindSourceDB1: TBindSourceDB; BindingsList1: TBindingsList; LinkPropertyToFieldText: TLinkPropertyToField; </strong> Layout1: TLayout;<strong> RadioButton1: TRadioButton; RadioButton2: TRadioButton; RadioButton3: TRadioButton; LinkPropertyToFieldIsChecked: TLinkPropertyToField; LinkPropertyToFieldIsChecked2: TLinkPropertyToField; LinkPropertyToFieldIsChecked3: TLinkPropertyToField; procedure RadioButton1Click(Sender: TObject);</strong> private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} <strong>procedure TForm1.RadioButton1Click(Sender: TObject); commencer if Sender=RadioButton1 then commencer if ne pas TRadioButton(Sender).IsChecked then commencer FDMemTable1.Edit; FDMemTable1.FieldByName('Value').AsString := 'Delphi'; FDMemTable1.Post; end; end autre if Sender=RadioButton2 then commencer if ne pas TRadioButton(Sender).IsChecked then commencer FDMemTable1.Edit; FDMemTable1.FieldByName('Value').AsString := 'Is'; FDMemTable1.Post; end; end autre if Sender=RadioButton3 then commencer if ne pas TRadioButton(Sender).IsChecked then commencer FDMemTable1.Edit; FDMemTable1.FieldByName('Value').AsString := 'Awesome'; FDMemTable1.Post; end; end; end;</strong> end. |
What does the Form component data binding objects look like for the demo?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
object BindSourceDB1: TBindSourceDB DataSet = FDMemTable1 ScopeMappings = <> Left = 144 Top = 224 end object BindingsList1: TBindingsList Methods = <> OutputConverters = <> Left = 20 Top = 5 object LinkPropertyToFieldText: TLinkPropertyToField Category = 'Quick Bindings' DataSource = BindSourceDB1 FieldName = 'Value' Component = Label2 ComponentProperty = 'Text' end object LinkPropertyToFieldIsChecked: TLinkPropertyToField Category = 'Quick Bindings' DataSource = BindSourceDB1 FieldName = 'Value' Component = RadioButton1 <strong> CustomFormat = 'IfThen(ToStr(%s)="Delphi",True, False)'</strong> ComponentProperty = 'IsChecked' end object LinkPropertyToFieldIsChecked2: TLinkPropertyToField Category = 'Quick Bindings' DataSource = BindSourceDB1 FieldName = 'Value' Component = RadioButton2 <strong> CustomFormat = 'IfThen(ToStr(%s)="Is",True, False)'</strong> ComponentProperty = 'IsChecked' end object LinkPropertyToFieldIsChecked3: TLinkPropertyToField Category = 'Quick Bindings' DataSource = BindSourceDB1 FieldName = 'Value' Component = RadioButton3 <strong> CustomFormat = 'IfThen(ToStr(%s)="Awesome",True, False)'</strong> ComponentProperty = 'IsChecked' end end |
What does the data bindings through LiveBindings look like?
Ready to learn how to program cross-platform apps like this?
Sign up for the Coding Boot Camp 2022 to learn to program. Topics include: Games, JavaScript, Web, Python, SQL, Databases, iOS, MacOS, Android, Mobile, Linux, Windows, Desktop, Server, and Arduino.