Reputation: 87
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?
Upvotes: 0
Views: 136
Reputation: 2758
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().
Upvotes: 0
Reputation: 613531
You'll need to have:
MainForm: TMainForm
, andOtherForm: 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.
Upvotes: 1