0
votes

I have a main form and tabsheet with some pages in it.

On 1st page there is a labeled edit,say,edit1. On 2 page there is a button that opens a new window(form). On this form there will be another labeled edit say edit2.

Question is : How can I compare value from edit1 with that of edit2?

2

2 Answers

1
votes

You'll need to have:

  1. A reference to the main form, say MainForm: TMainForm, and
  2. a reference to the other form, say OtherForm: TOtherForm.

Then you can write:

if MainForm.Edit1.Text = OtherForm.Edit2.Text then
  ....

That will work. But it would be better if your two forms exposed the text by way of public properties. That would avoid you needing to poke around at their internals.

0
votes

If the form is displayed by show() a possible solution might be this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  form2.Show();
  if self.edit1.text= form2.edit2.text
    then ShowMessage('Equals!');
end;

However, If form is a DMI child, this solution does not make much sense because there is no guarantee that the value changes. This works if you use ShowModal().