Home > Back-end >  Delphi DBRadioGroup usage
Delphi DBRadioGroup usage

Time:09-22

I want to use DBRadioGroup to display the database information
Such as: DBRadioGroup have "paid" and "non-payment" two item
When database PayState as "true" DBRadioGroup automatically check the "paid"
Non-payment by the same token,
Could you tell me how to implement this feature to?

CodePudding user response:

One, set DBRadioGroup binding data fields
1, DBRadioGroup binding field, should be a character type
Such as: set the field name "payment"
2 and DBRadioGroup. The Items, the corresponding data fields, a list of string
Such as: DBRadioGroup. Items, add "paid" and "non-payment" (design) can join)
3, the binding field
Code: DBRadioGroup1. The DataSource:=aDataSource1;
DBRadioGroup1. DataField:='payment;
So, DBGrid, change, DBRadioGroup choice, follow the string field, and change (selected)

Second, judge selection operation code
1, if DBRadioGroup. Items [DBRadioGroup ItemIndex]='paid'
Then the begin
//do you have a payment code
End
The else begin
If DBRadioGroup. Items [DBRadioGroup ItemIndex]='not paying'
Then the begin
//code executed your non-payment
end;
end;

2. Or:
If dbradiogroup. Items [0]. Checked then... ;//payment
If dbradiogroup. Items [1]. Checked then... ;//not paying

Say you understand?

CodePudding user response:

On the top floor,
The same as DBComboBox,

CodePudding user response:

reference 1st floor lyhoo163 response:
one, set DBRadioGroup binding data fields
1, DBRadioGroup binding field, should be a character type
Such as: set the field name "payment"
2 and DBRadioGroup. The Items, the corresponding data fields, a list of string
Such as: DBRadioGroup. Items, add "paid" and "non-payment" (design) can join)
3, the binding field
Code: DBRadioGroup1. The DataSource:=aDataSource1;
DBRadioGroup1. DataField:='payment;
So, DBGrid, change, DBRadioGroup choice, follow the string field, and change (selected)

Second, judge selection operation code
1, if DBRadioGroup. Items [DBRadioGroup ItemIndex]='paid'
Then the begin
//do you have a payment code
End
The else begin
If DBRadioGroup. Items [DBRadioGroup ItemIndex]='not paying'
Then the begin
//code executed your non-payment
end;
end;

2. Or:
If dbradiogroup. Items [0]. Checked then... ;//payment
If dbradiogroup. Items [1]. Checked then... ;//not paying

Say you understand?
what is your usage, please treat DBRadioGroup as an operational control to operate? I mean only the DBRadioGroup as a reflection of data control, show only some of the information in the database (or say I understand there is a problem? Actually I feel directly with DBEdit quite simple but still want to know what I think is not feasible=_=)

CodePudding user response:

With the DB control that is able to display the double can modify saved controls,
DBRadioGroup is indeed an operational control,
If only the DBRadioGroup as a reflection of data control, show only some of the information in the database, can use RadioGroup, RadioGroup display only, cannot be modified operation,
DBRadioGroup and DBEdit, DBCombobox, the function is same, only as a way to display and modify the operating mode,


  • Related