Recent

Author Topic: Read data from ComboBox1  (Read 5457 times)

zeljkoc

  • Full Member
  • ***
  • Posts: 145
    • Zeljko Cvijanovic
Read data from ComboBox1
« on: December 02, 2012, 07:38:15 pm »
How  read data from ComboBox1
example Label1.Caption: = ComboBox1.Caption or
Label1.Caption := ComboBox1.Text
android read ComboBox1

stab

  • Full Member
  • ***
  • Posts: 237
Re: Read data from ComboBox1
« Reply #1 on: December 04, 2012, 07:25:43 am »
Hi,

Do like this:
Label1.Caption: = ComboBox1.Items[ComboBox1.ItemIndex];

/stab :D

zeljkoc

  • Full Member
  • ***
  • Posts: 145
    • Zeljko Cvijanovic
Re: Read data from ComboBox1
« Reply #2 on: December 04, 2012, 05:31:54 pm »
read ComboBox1.ItemIndex exit and error

lazarus 1.1
date: 2012-11-26
FPC version 2.7.1
SVN revision
39375

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Read data from ComboBox1
« Reply #3 on: December 04, 2012, 05:42:29 pm »
ComboBox1.Text is correct way.

If you go for ComboBox1.ItemIndex, you need to check first that it is not -1. Because ComboBox1.Items[-1] will result bad error. If Combobox value is different than any item in its list, then Itemindex may be -1. You can also select it from the Object properties window, to give a reasonable start value. So this way only really works if typing to ComboBox is not allowed (check style properties).

zeljkoc

  • Full Member
  • ***
  • Posts: 145
    • Zeljko Cvijanovic
Re: Read data from ComboBox1
« Reply #4 on: December 04, 2012, 06:11:25 pm »
work Windows not work android

procedure TForm1.Button3Click(Sender: TObject);
begin
  if ComboBox1.ItemIndex <> -1 then
    Label1.Caption := ComboBox1.Items[ComboBox1.ItemIndex];
end;

ComboBox1.ItemIndex = -1

component:
 
 DBLookupComboBox1: TDBLookupComboBox;

not result DataSource, DataField   not add table

Windows work not work android

 

TinyPortal © 2005-2018