-3

I'm working on a small Delphi project. I'm trying to link an TEdit with another TEdit.

When the user types his username and password and logs in, the username should show up in the next Form. I've created a TEdit on the next Form, but I don't know to link it.

Can someone please help me?

I'm using Delphi 10.4!

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Franklin
  • 1
  • 1

2 Answers2

3

Well... you actually can link one TEdit to another TEdit (or, for that matter, any other component/control/property to any other component/control/property), but you will need to use LiveBinding, or kbmMW SmartBinding.

In kbmMW SmartBinding, you can do it in a couple of ways. In code:

Binding.Bind(Edit1,'Text',Edit2,'Text');

One way binding. If you change Edit1.Text somehow (by typing or by code), Edit2.Text will automatically be updated. But, if you change Edit2.Text, Edit1.Text will not change.

Binding.Bind(Edit1,'Text',Edit2,'Text',[mwboTwoWay]);

Two way binding. If you change either Edit1 or Edit2's Text property, the other will also be changed.

Or, you can do it at design-time by setting the Edit1.Text property to:

{Edit2.Text, twoWay:true}

And then call Binding.AutoBind(Self) in the Form's OnCreate event handler.

kbmMW SmartBinding is included in kbmMW Community Edition for Delphi 10.4 Sydney, which is freely available for download at https://portal.components4developers.com

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Kim Madsen
  • 242
  • 2
  • 2
1

You can't link TEdit controls together. What you need to do is when the user logs in, read the 1st TEdit's Text property and save it to a String, then when the next Form is shown, assign that String to the 2nd TEdit's Text property.

For example:

user: String;
...
user := Form1.UserEdit.Text;
...
Form2.UserEdit.Text := user;
Andreas Rejbrand
  • 105,602
  • 8
  • 282
  • 384
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • How do i do that? please help i really need it! – Franklin Sep 05 '21 at 19:51
  • 1
    @Franklin Really? Working with variables and reading/writing property values are very basic foundation skills in Delphi. If you don't understand how to do this, I suggest you focus on building up those skills first before working with GUIs. In any case, I have added an example to my answer. – Remy Lebeau Sep 05 '21 at 20:56
  • god bless you! i'm doing my best! i'll get there one day! don't worry! i promise! – Franklin Sep 05 '21 at 22:23
  • Sir can you please tell from where do i start? show me the right way please!!! – Franklin Sep 05 '21 at 22:28
  • 2
    @Franklin: Not to be rude or anything, but the "right way" is *definitely* to buy (or find) a good introductory book about Delphi programming. That is by far the best way to properly learn everything you need to know. – Andreas Rejbrand Sep 06 '21 at 06:31