Solved

how to get text values from checklistbox?

Posted on 2004-08-23
3
273 Views
Last Modified: 2010-04-05
I want to get text values from checklistbox...

procedure TForm1.CheckListBox1Click(Sender: TObject);
begin
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('Select id, picture from people where now = 'CHECKED.ITEM.TEXT'');
ADOQuery1.Open;
end;
0
Comment
Question by:selas
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 11868364
well, no delphi on hand yet, but i would guess

for i := 0 to checklistbox1.items.count-1 do
  if checklistbox1.items[i].checked then
    result := checklistbox1.items[i];

//be aware that multiple items could be checked

meikl ;-)
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11868505
procedure TForm1.Button1Click(Sender: TObject);
var
  I:      Integer;
  S:      string;
begin
  S := '(';
  for I := 0 to CheckListBox1.Items.Count-1 do
    if CheckListBox1.Checked[I] then
      S := S + CheckListBox1.Items[I] + ',';
  if S<>'(' then
  begin
    Delete(S, Length(S), 1);
    S := S + ')';
    ADOQuery1.SQL.Text :=''
                       + ' Select id, picture from people'
                       + ' where now in '
                       + S
                       + '';
    ADOQuery1.Open;
  end;
end;
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 11868529
procedure TForm1.Button1Click(Sender: TObject);
var
  I:      Integer;
  S:      string;
begin
  S := '(';
  for I := 0 to CheckListBox1.Items.Count-1 do
    if CheckListBox1.Checked[I] then
      S := S + CheckListBox1.Items[I] + ',';
  if S<>'(' then
  begin
    Delete(S, Length(S), 1);
    S := S + ')';
    ADOQuery1.Active := False;
    ADOQuery1.SQL.Text :=''
                       + ' Select id, picture from people'
                       + ' where now in '
                       + S
                       + '';
    ADOQuery1.Open;
  end;
end;
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 89
delphi exception 7 58
find a node in VST 2 46
Error E2158 compiling with Delphi XE10 Seattle 2 45
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now