Solved

how to get text values from checklistbox?

Posted on 2004-08-23
3
288 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
[X]
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
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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