Recent

Author Topic: DBlookupcombobox question  (Read 603 times)

Petrus Vorster

  • Jr. Member
  • **
  • Posts: 82
DBlookupcombobox question
« on: September 10, 2024, 11:45:12 am »
Hi All.

Please keep in mind I am still very new to this platform and still learning a great deal.

I have build a little tool that uses a few DBlookupcomboboxes and they do great for what i need them for.
I do have one which contains cellphone numbers and I would like to limit the user from entering anything else but numbers into it. The method i use on e.g. a Tedit during the keypress has zero effect on the Tlookupcombobox.

Also, can I want to set a maxlength on it, if that is possible. Just to prevent people typing in garbage and causing trouble later.

Thank you for all the help, I have learned a great deal in a very short time!

Regards,

Peter

rvk

  • Hero Member
  • *****
  • Posts: 6575
Re: DBlookupcombobox question
« Reply #1 on: September 10, 2024, 12:23:06 pm »
I have build a little tool that uses a few DBlookupcomboboxes and they do great for what i need them for.
I do have one which contains cellphone numbers and I would like to limit the user from entering anything else but numbers into it. The method i use on e.g. a Tedit during the keypress has zero effect on the Tlookupcombobox.
Can you show code as to what you already tried?

Also, can I want to set a maxlength on it, if that is possible. Just to prevent people typing in garbage and causing trouble later.
What is the length of the field connected to it?
Usually data-aware components will limit the length to the maximum length of that field.

Zvoni

  • Hero Member
  • *****
  • Posts: 2738
Re: DBlookupcombobox question
« Reply #2 on: September 10, 2024, 12:45:07 pm »
Quote
The method i use on e.g. a Tedit during the keypress has zero effect on the Tlookupcombobox.

I've been looking through the available controls....
There is no TLookupComboBox.... Did i miss something?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Petrus Vorster

  • Jr. Member
  • **
  • Posts: 82
Re: DBlookupcombobox question
« Reply #3 on: September 10, 2024, 01:04:41 pm »
Typos. Pardon please.

Tdblookupcombobox.

The field length is set to 10 characters (string). That works perfectly if you edit inside the connected Tdbgrid, but not in the connected Tdblookupcombobox.

so I tried to limit the typing to :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DBLookupComboBox3KeyPress(Sender: TObject; var Key: char);
  2. begin
  3.    if not (Key in ['0'..'9', '.', #8, #9]) then Key := #0;
  4. end;  

That works in e.g. Tedit, but not here.

The Maxlength is not a Property of the control, and trying to do that with my limited skills had proven disastrous.

I am starting to wonder if it would not be simpler to use a normal Tcombobox and run a loop through the records to populate the Cellnumbers?
What would you have done?

-PEter

rvk

  • Hero Member
  • *****
  • Posts: 6575
Re: DBlookupcombobox question
« Reply #4 on: September 10, 2024, 01:15:40 pm »
so I tried to limit the typing to :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DBLookupComboBox3KeyPress(Sender: TObject; var Key: char);
  2. begin
  3.    if not (Key in ['0'..'9', '.', #8, #9]) then Key := #0;
  4. end;  

That works in e.g. Tedit, but not here.
Are you sure you have this event connected to your DBLookupComboBox3 ??
(Look in the event tab in the object inspector)

For me it's working.

The Maxlength is not a Property of the control, and trying to do that with my limited skills had proven disastrous.
No, the MaxLength is a property of TDBLookupComboBox.Field (i.e. TDBLookupComboBox.Field.DataSize).
But that should be done automatically.


Petrus Vorster

  • Jr. Member
  • **
  • Posts: 82
Re: DBlookupcombobox question
« Reply #5 on: September 10, 2024, 01:43:36 pm »
Hi.

No worries further.
I have replaced the Tdblookupcombox with a normal Tcombobox and just filled the items with the specific field in the record.
It does the same trick and I can set a Maxlength.

Thanks for your advice.
-Peter

 

TinyPortal © 2005-2018