?
Solved

How to update TEdit control on Main form with the input of a TEdit on a dialog after pressing ok button?

Posted on 2004-11-02
6
Medium Priority
?
261 Views
Last Modified: 2010-04-05
Hi Guys!

I have a Main Form with a TEdit and a TButton on it. Also I have a Dialog with a TEdit on it plus two buttons. CLicking the button on the main form pops up the dialog with the TEdit on it. Now I want to update the TEdit on the mainform with the contents of the TEdit on the dialog after button1 from the dialog is pressed while pressing button2 should cancel this operation leaving the edit on the mainform untouched.

My goal: popping up the dialog, insert some characters into the dialogs TEdit and only after I press OK button of the dialog, the contents of hte main forms TEdit is changed (immediately) otherwise it remains the same (untouched).

I gave my best shot this afternoon but failed to achieve this. Providing a working sample grants you the points. Let me know if my information is insufficient ok?

Regards from Holland,

PeterdeB

0
Comment
Question by:PeterdeB
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:LRHGuy
ID: 12475396
in dialog form:

on buttonclick:

  mainform.teditname.text:=dialogform.teditname.text

in other words, in the button click on the dialog that is "accepting" the input, push the value into the main form by referencing the field on the main form. You'll need to include the main form's unit in the implementation section of the dialogue unit.
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 500 total points
ID: 12475560
create a standard dialog with 2 buttons (file - new- dialog- standard dialog) - we'll assume this is "unit2/form2"
the "ok" button has a modalresult of mrOK, and the "cancel" button by default has a modalresult of mrCancel;
put your edit on there and call it something unique like eMyDialogEddit, and call it like this from your main form

uses unit2;

with TForm2.create do
try
    if ShowModal = mrOK then // ok button pressed
      edit1.text := eMyDialogEddit.Text;  
finally
    free;
end;
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 12475704
oops, that should say with TForm2.create(self)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:PeterdeB
ID: 12475924
Hi TheRealLoki you bring a smile upon my face with your comment since I figured that out by now too LOL!! Nevertheless it goes without saying that you get the points, your answer is PERFECT!!

Needless to post the code here but I'll do it anyway:

 with TfrmWizard.create(Self) do
try
    if ShowModal = mrOK then // ok button pressed

        gbTabForum.Caption := edit1.text;
         edtURL.Text := edit2.Text;
       edtUserName.Text := edit3.Text;
        edtPassword.Text := edit4.Text;
       edtBtnText.Text :=  edit5.Text;
finally
    free;
end;

Tnx a lot!!!

PeterdeB
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 12477517
you're welcome. don't forget to use a begin..end block if you want to set multiple edit boxes etc.

btw, if you wanted to use the same dialog to "edit" your settings, you could do

with TfrmWizard.create(Self) do
try
// set text
        edit1.text := gbTabForum.Caption;
        edit2.Text := edtURL.Text;
        edit3.Text := edtUserName.Text;
        edit4.Text := edtPassword.Text;
        edit5.Text := edtBtnText.Text;
// now display the dialog so the user can edit
    if ShowModal = mrOK then // ok button pressed
    begin // YOU NEED THIS BLOCK IF YOU ARE SAVING MORE THAN 1
        gbTabForum.Caption := edit1.text;
        edtURL.Text := edit2.Text;
        edtUserName.Text := edit3.Text;
        edtPassword.Text := edit4.Text;
        edtBtnText.Text :=  edit5.Text;
    end; // of user pressed OK
finally
    free;
end;
0
 

Author Comment

by:PeterdeB
ID: 12479510
Thanks TheRealLoki! I was just struggling with several TEdits so your comment helped me out once more!!

My regards!

PeterdeB
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question