Board index » delphi » "Data-aware" TForm.captions

"Data-aware" TForm.captions

I want the heading of a window to display some table data in its
caption string. This way the user sees exactly which record he/she is
working on.

Data-aware headings on a form canvas are simple:
- A configured TDBEDit "looks" like a heading
- The field is linked via adataset
- Headings display correctly automatically

However, one wants this heading in the TForm.caption, not on the TForm
canvas.

For this one needs to track:
- Has the record pointer moved
- Has the other window been created

For simple dependencies, DataSouce.OnDataChange() seem to do the
trick:
- If the DataSouce.state = dsBrowse and
  Field=NIL then the record pointer moved.
- The TForm.caption is updated here.

For multiple dependencies, start-up faults can occur:
- The other form has not been created
- Both forms need each other
- Changing the "create order" won't resolve
  the conflict

This seems to mean "fixing" the caption update in many different event
handlers throughout the application.

Defining the TForm.caption by reference to the dataset directly, that
would be neat, if possible.

Does anyone know of a custom TForm component with a "data-aware"
caption?

Email appreciated.
Matthew

 

Re:"Data-aware" TForm.captions


On 17/09/1996 18:23, in message <51mj7g$...@power2.power.net.uk>, Matthew

Quote
<Com...@lottery.powernet.co.uk> wrote:
> Data-aware headings on a form canvas are simple:
> - A configured TDBEDit "looks" like a heading
> - The field is linked via adataset
> - Headings display correctly automatically

Use the TDBEdit.ONChange event. Look up on the TDBEdit Text and/or Value
Fields. Then use the OnChange to set the Form.Caption.

Here is an example:

procedure Form1.DBEdit1Change(Sender: TObject);
begin
  Form1.Caption := Format('Form1 [%s]',[DBEdit1.Text]);
  {I use Format, tis more efficient than using the + operator}
end;

Possibly the same with form2.Create.

Use added variables in the form to be created, set the variable, and then set
the OnShow to reflect the new value of the variable.

Hope this helps. Feel free to mail me.

Stefan

Other Threads