Solved

how to get text values from checklistbox?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

785 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