[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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
?
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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!

 

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 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