Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling a DBCtrlGrid

Status
Not open for further replies.

RonR51

Programmer
Apr 19, 2001
18
AU
I am using a DBCtrlGrid to display several records on screen at once. The control grid has a DBCheckBox and a DBEdit on it. I am trying to control the Visible state of the DBEdit according to the Checked state of the DBCheckBox.

When a checkbox is clicked (I am using the OnClick event), the corresponding DBEdit behaves correctly, however all the other DBEdits (for the other records) change state whenever I move to another record.

I notice that the controls placed on a DBCtrlGrid actually appear with the Form as their parent in the object inspector.

Is there any way to determine which instance of the controls I am dealing with at any one time and limit the effects to just one record at a time.

Thanks for any help

RonR
 
Hi,

If I understand you are trying to have non data aware controls controled by the data of a record and when you change records you want the controls to update to show the status of the current record.

If this is so, you can place the code for your controls in the DataChange on the DataSource.

Example:
Code:
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
checkbox1.Checked := table1.FieldByName('selected').asBoolean;
end;

The code above changes the state of Checkbox1 dependant on the value of the field selected in Table1.

Kind Regards, Paul Benn

**** Never Giveup, keep trying, the answer is out there!!! ****
 
Thanks for the reply Paul, but you have misunderstood my problem.

All the controls are data aware controls and they behave correctly according to the contents of the data fields they are attached to. My problem is as follows. I am trying to hide a data aware edit box and only show it if the data aware check box on the same record is checked. The checkboxes behave perfectly and change state according to the contents of the boolean field and the users mouse clicks. It is the DBEdit boxes that do not follow the state of the associated checkboxes.

I am trying to use the Checked state of the DBCheckbox rather than the value of the dataset field to trigger the changing of the DBEdit Visible status because the record does not get updated until a new record is selected or I deliberately Post the record evrey time the checkbox is clicked.

Ron R
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top