修改一下 procedure TXSpaceMutiSelectComboBox.ListBoxMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if (Sender As TCheckListBox).ItemIndex = -1 then exit; if X > 15 then begin Toggle( (Sender As TCheckListBox).ItemIndex ); end; end;
procedure TXSpaceMutiSelectComboBox.DropDown; var ScreenPoint : TPoint; nDropDown, i,iRes : integer; strTmp: string; begin Inherited; if ( DropDownCount <= Items.Count ) then nDropDown := DropDownCount else nDropDown := Items.Count;
// Assign Form coordinate and show ScreenPoint := Parent.ClientToScreen( Point( self.Left, self.Top+self.Height ) ); FListBox.Font := self.Font; FListBox.Color := self.Color; FListBox.ItemHeight := self.ItemHeight; FListBox.Items.Assign( Items );
with FDDForm do begin Font := self.Font; Left := ScreenPoint.X; Top := ScreenPoint.Y; Width := self.Width; Height := ( nDropDown * self.ItemHeight ) + 5; if FHorzScrollBar then Height := Height + Horizontal_ScrollBar; Color := clAqua; BorderStyle := bsNone; OnDeactivate := ClosePopUp; end; if FHorzScrollBar then SendMessage(FListbox.Handle, LB_SetHorizontalExtent, 1000, Longint(0)); FDDForm.Show;
strTmp := self.Text; while Pos(',', strTmp) > 0 do begin iRes := FListBox.Items.IndexOf(Copy(strTmp, 1, Pos(',', strTmp)-1)); if iRes >= 0 then begin FListBox.Checked[iRes] := True; end; Delete(strTmp, 1,Pos(',', strTmp)); end; if strTmp <> '' then begin iRes := FListBox.Items.IndexOf(strTmp); if iRes >= 0 then begin FListBox.Checked[iRes] := True; end; end; // for i:=0 to FSelectIndex.Count-1 do // FListBox.Checked[StrToInt(FSelectIndex.Strings[i])]:= True; end;