Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to get text values from checklistbox?

Posted on 2004-08-23
3
284 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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