Recent

Author Topic: I have a combobox with autocomplete turned on  (Read 617 times)

vonskie

  • Full Member
  • ***
  • Posts: 186
I have a combobox with autocomplete turned on
« on: May 24, 2024, 04:48:40 pm »
I have a combobox with autocomplete turned on

When I type in part of the mac it will pull up the entry as its supposed to but the on change event does not fire. I have tried onkeypress and it did not work either

What event can I use?

Please help!

procedure Tformblackhole.ComboBoxcurrentmacChange(Sender: TObject);

 var
  SelectedItem: string;
  SeparatorPos1, SeparatorPos2: Integer;
  MacAddress, Vlan, Reasontxt: string;
begin
  SelectedItem := ComboBoxcurrentmac.Text;

  // Find the positions of both separators (colons)
  SeparatorPos1 := Pos(':', SelectedItem);
  SeparatorPos2 := Pos(':', SelectedItem, SeparatorPos1 + 1); // Start search after the first colon

  if (SeparatorPos1 > 0) and (SeparatorPos2 > 0) then  // Check if both colons are found
  begin
    // Extract MAC, VLAN, and Reason
    MacAddress := Copy(SelectedItem, 1, SeparatorPos1 - 1);
    Vlan := Copy(SelectedItem, SeparatorPos1 + 1, SeparatorPos2 - SeparatorPos1 - 1);
    Reasontxt := Copy(SelectedItem, SeparatorPos2 + 1, Length(SelectedItem) - SeparatorPos2);

    // Set the values of mac, vlan, and reason text fields
    editmac.Text := MacAddress;
    spineditvlan.Text := Vlan;
    reason.Text := Reasontxt; // Assuming you have an editreason text field
  end;
end;                           

vonskie

  • Full Member
  • ***
  • Posts: 186
Re: I have a combobox with autocomplete turned on
« Reply #1 on: May 24, 2024, 05:08:30 pm »
Onselect worked!

Joanna

  • Hero Member
  • *****
  • Posts: 815
Re: I have a combobox with autocomplete turned on
« Reply #2 on: May 24, 2024, 09:57:04 pm »
Glad you solved it.
Please use code tags
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

 

TinyPortal © 2005-2018