Tchecklistbox

Please discuss general Delphi programming topics here.

Tchecklistbox

Postby sekar1 » September 4th, 2007, 8:39 am

there are some ten itemstrings in the Tchecklistbox, i want to highlight only one item in single time. if there is an item already checked means it would be unchecked and the new item i clicked is to be checked. generally for this we will use multiselect option.

i also used the checklistbox1.multiselect:= False; this is not working.. can any better way there to do this?
sekar1
Junior Member
Junior Member
 
Posts: 25
Joined: December 21st, 2006, 5:55 am

Making TCheckList box such as Radiogroup!

Postby Sezar » September 4th, 2007, 1:59 pm

Hi,try this code: :)
Code: Select all
procedure TForm1.CheckListBox1ClickCheck(Sender: TObject);
var
 i:Integer;
 CheckedCount:Integer;
begin
{--- First,We get the count of checked items ---}
  CheckedCount:=0;
  for i:=0 to CheckListBox1.Items.Count-1 do
    if CheckListBox1.Checked[i] then
       Inc(CheckedCount);
  if (CheckedCount<=1) then Exit;
{--- Then we set all checked to false,except the selected item ---}
  for i:=0 to CheckListBox1.Items.Count-1 do
    if (CheckListBox1.Checked[i])and
((Sender asTCheckListBox).ItemIndex<>i) then
       CheckListBox1.Checked[i]:=False;
end;
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby sekar1 » September 5th, 2007, 6:00 am

Thanks for your help... it is working fine...
sekar1
Junior Member
Junior Member
 
Posts: 25
Joined: December 21st, 2006, 5:55 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron