Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TLMDCheckListComboBox -setting Checklistbox.Value

When setting the CheckListbox.Value property of a LMDCheckListComboBox, it correctly checks the respective items in the dropdown list box, however, the combobox does not reflect which items are checked until I manually check or uncheck one from the dropdown, in which case all that are checked then show up in the combobox.  Is there something I need to call to update the combobox after setting the value of the Checklistbox.Value?  Or is this something I have to populate myself in code?

Comments

  • 4 Comments sorted by Votes Date Added
  • Unfortunately, TLMDCheckListComboBox does not provide a property, which will be equivalent to TLMDCheckListBox.Value property. Note, that in combo-box Value property is of type string, while in list-box - of type Int64. And so,  while list-box Value property is a bit mask for checked items, combo-box's Value property is just an equivalent of standard TComboBox.Value and works similarly.
    You should use TLMDCheckListComboBox.Checked property instead.
  • Understood.  I fill the TLMDCheckListComboBox.Value property in my code based on what is checked.  It just seemed that since the combobox value property gets filled properly when checking or unchecking an item in the listbox, it fills that combobox Value string with all previously and newly checked items.  It would be nice to have it automatically call the same procedure when setting the listbox value as it does when checking a new checkbox so that the combo box value gets populated without having to do it in my code.  I hope that made some sense.  No big deal.
  • Since setting the TLMDCheckListComboBox.CheckListbox.Value property only handles the first 32 items even though it is a 64bit value, I had to do the following to support up to 64 items.  I've added a solution here in case it helps others:

    procedure SetCheckList(pCombo: TLMDCheckListComboBox; pBits: Int64);
    var
      vBit: Integer;
      vBitMask: Int64;
    begin
      for vBit := 0 to pCombo.Items.Count-1 do
      begin
        vBitMask := Int64(1) shl vBit;
        pCombo.Checked[vBit] := ((pBits and vBitMask) <> 0);
      end;
    end;

    function GetCheckListBits(pCombo: TLMDCheckListComboBox): Int64;
    var
      vBit: Integer;
      vBitMask: Int64;
    begin
      Result := 0;
      for vBit := 0 to pCombo.Items.Count-1 do
      begin
        if pCombo.Checked[vBit] then
        begin
          vBitMask := Int64(1) shl vBit;
          Result := Result or vBitMask;
        end;
      end;
    end;
  • edited March 2018 Posts: 0 Accepted Answer Vote Up0Vote Down

    Its probablypossible for TLMDCheckListBox.Value property to support all 64 bits. I've added this as TODO item for the next releas:
    https://git.lmd.de/customer/lmdvcl/issues/6

Sign In or Register to comment.