Recent

Author Topic: Display the Selected item of ListBox1 in Edit1  (Read 6514 times)

Deepaak

  • Sr. Member
  • ****
  • Posts: 454
Display the Selected item of ListBox1 in Edit1
« on: October 14, 2017, 06:16:47 am »
There are two Controls
1. Edit1
2. ListBox1

Eg. ListBox1 contain 10 Items.
So, When a user click item1 it should get displayed in Edit1 or when clicked item 2 it should get displayed in Edit1.
Holiday season is online now. :-)

Eugene Loza

  • Hero Member
  • *****
  • Posts: 674
    • My games in Pascal
Re: Display the Selected item of ListBox1 in Edit1
« Reply #1 on: October 14, 2017, 07:07:59 am »
try ListBox1.GetSelectedText; or a more advanced listbox1.Selected[j]; (in case multiselect is possible).
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Display the Selected item of ListBox1 in Edit1
« Reply #2 on: October 14, 2017, 07:12:59 am »
Code: Pascal  [Select][+][-]
  1. procedure TEvsFontEditFrame.lbFontNameClick(Sender :TObject);
  2. begin
  3.   //a listbox named lbFontName and an edit named edtFontName.
  4.   edtFontName.Text := lbFontName.Items.Strings[lbFontName.ItemIndex];
  5.   edtFontName.SelectAll;
  6. end;  
  7.  
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018