Page 1 of 1

Tchecklistbox

PostPosted: September 4th, 2007, 8:39 am
by sekar1
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?

Making TCheckList box such as Radiogroup!

PostPosted: September 4th, 2007, 1:59 pm
by Sezar
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;

PostPosted: September 5th, 2007, 6:00 am
by sekar1
Thanks for your help... it is working fine...