Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to get text values from checklistbox?

Posted on 2004-08-23
3
Medium Priority
?
328 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 2000 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 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