ler a propriedade SelectedValue de um combobox ou listbox
Saudações!
Como ler a propriedade SelectedValue de um combobox ou listbox por código?
O mais proximo que cheguei foi:
if Assigned(ComboBox1.Selected) then
ShowMessage(IntToStr(Integer(ComboBox1.Selected.Data)));
ou
ShowMessage(ComboBox1.ListItems[ComboBox1.ItemIndex].ItemData.Text);
Mais retorna vazio.
Como ler a propriedade SelectedValue de um combobox ou listbox por código?
O mais proximo que cheguei foi:
if Assigned(ComboBox1.Selected) then
ShowMessage(IntToStr(Integer(ComboBox1.Selected.Data)));
ou
ShowMessage(ComboBox1.ListItems[ComboBox1.ItemIndex].ItemData.Text);
Mais retorna vazio.
Tecnolens Ltda
Curtidas 0
Respostas
Romulo Silva
19/05/2014
procedure TForm1.Button1Click(Sender: TObject);
var
I : Integer ;
combo : TComboBox;
begin
for I := 0 to ComponentCount - 1 do
begin
if Components[I] is TComboBox then
begin
combo := Components[I] as TComboBox;
// exemplo 01
if combo.Name = 'ComboBox1' then
showmessage(combo.Text);
// exemplo 02
if combo.Text = 'ComboBox1' then
showmessage(combo.Text);
end;
end;
end;
var
I : Integer ;
combo : TComboBox;
begin
for I := 0 to ComponentCount - 1 do
begin
if Components[I] is TComboBox then
begin
combo := Components[I] as TComboBox;
// exemplo 01
if combo.Name = 'ComboBox1' then
showmessage(combo.Text);
// exemplo 02
if combo.Text = 'ComboBox1' then
showmessage(combo.Text);
end;
end;
end;
GOSTEI 0
Alan Souza
19/05/2014
ShowMessage(ListBox1.Items[ListBox1.ItemIndex]);
GOSTEI 0
Tecnolens Ltda
19/05/2014
Agradeço as respostas, mas Criei um novo tópico explicando melhor: Firemonkey: Ler a propriedade SelectedValue de um combobox ou listbox.
GOSTEI 0