Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

EditBox Problem

Hi,

I have two EditBoxes. At run-time, as I input into the EditBox1, the cursor stays in EditBox1 and I have to click EditBox2 to input something to EditBox2. Well, if I wanted to have the cursor "moved" to EditBox2 when I have input a specific string in EditBox1, how can this be achieved?

The following code didn't work:

procedure TMainForm.EditBox1(Sender: TObject);
begin
If EditBox1.Text = DesiredString then
EditBox2.SelectAll;
end;


Thanks for your attention,
Roger

Comments

  • zibadianzibadian Member Posts: 6,349
    : Hi,
    :
    : I have two EditBoxes. At run-time, as I input into the EditBox1, the cursor stays in EditBox1 and I have to click EditBox2 to input something to EditBox2. Well, if I wanted to have the cursor "moved" to EditBox2 when I have input a specific string in EditBox1, how can this be achieved?
    :
    : The following code didn't work:
    :
    : procedure TMainForm.EditBox1(Sender: TObject);
    : begin
    : If EditBox1.Text = DesiredString then
    : EditBox2.SelectAll;
    : end;
    :
    :
    : Thanks for your attention,
    : Roger
    :
    :
    You need to write the Edit1.OnChange event for that effect. Here is the code for such an event:
    [code]
    procedure TfrmMain.Edit1Change(Sender: TObject);
    begin
    if Edit1.Text=DesiredString then
    Edit2.SetFocus;
    end;
    [/code]
  • rrrrr12345rrrrr12345 Member Posts: 56
    : : Hi,
    : :
    : : I have two EditBoxes. At run-time, as I input into the EditBox1, the cursor stays in EditBox1 and I have to click EditBox2 to input something to EditBox2. Well, if I wanted to have the cursor "moved" to EditBox2 when I have input a specific string in EditBox1, how can this be achieved?
    : :
    : : The following code didn't work:
    : :
    : : procedure TMainForm.EditBox1(Sender: TObject);
    : : begin
    : : If EditBox1.Text = DesiredString then
    : : EditBox2.SelectAll;
    : : end;
    : :
    : :
    : : Thanks for your attention,
    : : Roger
    : :
    : :
    : You need to write the Edit1.OnChange event for that effect. Here is the code for such an event:
    : [code]
    : procedure TfrmMain.Edit1Change(Sender: TObject);
    : begin
    : if Edit1.Text=DesiredString then
    : Edit2.SetFocus;
    : end;
    : [/code]
    :


    I forgot to type Change here, but SetFocus is exactly what I needed, I find it hard to know which event to use. Thanks for your help
Sign In or Register to comment.