Recent

Author Topic: DBLookUpCombo question ...  (Read 8174 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
DBLookUpCombo question ...
« on: November 07, 2023, 03:33:44 pm »
In developing this app, I came from Delphi 7 long time ago.  What I'm looking for is a component in Laz similar to DBLookUpCombo for example to lookup the correct country code for the Country field that's two char. wide in the table.  But, can't find a component LookUp that will list the Countries table which the first field is the country code and the second field is the full country name.  This way the the user can lookup Canada but the drop-down lists both the country code and the country name in the drop-down list.  They select Canada and CA from list which displays countries, both the code in one column and the full country name in the second column. When the user scrolls down the drop-down list and selects Canada, the country code CA  is returned to form field for Country.
Next, going to check out DBLookUpListBox to see if that provides the behavior I'm looking for...
Tks in advance...

korba812

  • Sr. Member
  • ****
  • Posts: 482
Re: DBLookUpCombo question ...
« Reply #1 on: November 07, 2023, 05:52:57 pm »
Check out these components: TJvDBLookupCombo from JVCL package or TRxDBLookupCombo from RX package. Both have the ability to display multiple columns in a drop-down list. And both are available from Lazarus CCR repository or OPM.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo question ...
« Reply #2 on: November 07, 2023, 08:23:32 pm »
Thanks Korba812, I figured there was probably a solution to my request.
Take care ...  :)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo question ...
« Reply #3 on: November 08, 2023, 12:49:45 am »
Korba812, where do I go to find these packages.  This is what I've been able to find searching:

JvDB
Depends on packages JvCore, JvStdCtrls, and JvCtrls
Data-aware controls
TJvSearchEdit: a TEdit with incremental search capabilities within a field of a DataSet.
TJvDBLookupList and TJbDBLookupCombo: lookup controls with additional features:
ocan display more than one column (the LookupDisplay property can contain a list of columns separated by a semicolon, the column width is calculated based on Field.DisplayWidth)
ocan display pictures (OnGetImage/OnGetImageIndex events)
oconfigurable empty value (DisplayEmpty,EmptyItemColor,EmptyStrIsNull,EmptyValue)
TJvDBTreeView: a treeview constructed from database records. Link the unique ID field to "MasterField", the ID field of the parent node to "DetailField", and the field with the node text to "ItemField". Optionally, the field "IconField" provides the image index for the ImageList. "StartMasterValue" is the beginning level to start building the TreeView, 0 = start from the root items, 1 = start from the second level, and so on.
TJvDBCalcEdit: a numeric edit box which opens a calculator dialog.
  Note: The packages JvStdCtrlsLazR and JvCtrlsLazR must have been compiled before this package can be installed.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: DBLookUpCombo question ...
« Reply #4 on: November 08, 2023, 01:01:11 am »
Korba812, where do I go to find these packages.  This is what I've been able to find searching:
Korba is probably able to answer that better than I am but I do not know in what timezone he is.

If you open package/online package manager a window will pop up. You can either search for jvcl or scroll down the list and locate jvcllaz. If you click the plus sign OPM will show which packages/controls will be installed that belongs to that 'main' package. Select the main entry for JVCLlaz and press the install button at the bottom. Everything should then install automatically for you.

Same for package RX.

See also wiki: Online Package Manager

« Last Edit: November 08, 2023, 01:09:46 am by TRon »
Today is tomorrow's yesterday.

korba812

  • Sr. Member
  • ****
  • Posts: 482
Re: DBLookUpCombo question ...
« Reply #5 on: November 08, 2023, 01:14:36 am »
Yes, exactly this package. You can install it from OPM, as TRon mentioned. At the bottom of the page where you found this description (https://wiki.freepascal.org/JVCL_Components) you will find where to download from and how to install.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo question ...
« Reply #6 on: November 08, 2023, 01:44:15 am »
Alright! Thanks Korba & Tron.

jamie

  • Hero Member
  • *****
  • Posts: 7300
Re: DBLookUpCombo question ...
« Reply #7 on: November 08, 2023, 02:12:03 am »
I Suppose one could down load the 3166 CSV file and parse it to a drop down control.
The only true wisdom is knowing you know nothing

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo question ...
« Reply #8 on: November 10, 2023, 11:07:09 pm »
I have 2 tables, one with the 3166 US & CA, code and full name and another 3166 with country codes and their full name.

Also, with the TJvDbLookUpCombo component, what is the LookUpFormat property used for?

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: DBLookUpCombo question ...
« Reply #9 on: November 10, 2023, 11:17:48 pm »
Also, with the TJvDbLookUpCombo component, what is the LookUpFormat property used for?
https://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvDBLookupCombo.LookupFormat
Quote
Use LookupFormat to display the lookup field values in a specific format in the lookup list. The format string must have the same number of format specifiers as the number of fields (specified by LookupDisplay). The only allowed format specifier is "%s".
For example, you have 3 fields in the lookup table: FIRSTNAME, LASTNAME and AGE. If these fields have the values 'John', 'Doe', 25 resp. then you want it to be displayed as 'Doe, John (25)'. In this case you have to set the properties as follows: ListStyle := lsDelimited;
LookupDisplay := 'LASTNAME;FIRSTNAME;AGE';
LookupFormat := '%s, %s (%s)';
Today is tomorrow's yesterday.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 397
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DBLookUpCombo question ...
« Reply #10 on: November 11, 2023, 02:15:12 pm »
TRon, that's great!  Is there a doc/manual somewhere that documents these property values?
The LookupDisplay property was what I expected, thanks!

wp

  • Hero Member
  • *****
  • Posts: 13197
Re: DBLookUpCombo question ...
« Reply #11 on: November 11, 2023, 04:08:45 pm »
TRon, that's great!  Is there a doc/manual somewhere that documents these property values?
The LookupDisplay property was what I expected, thanks!
There is a sample project in the "examples" folder of the JVCL installation for Lazarus. Maybe it helps to get you started.

A very short documentation for the Lazarus port is contained in https://wiki.freepascal.org/JVCL_Components#JvDB.

Just found the "official" documentation of the JVCL components at sourceforge. Among other formats it is available also as a pdf (https://sourceforge.net/projects/jvcl/files/JVCL%20Help%20Files/JVCL%203.41%20Help/jvcl-3.41-pdfhelp.zip/download). But note that it is for v3.4.1 of the delphi version, and may be out-dated and not applicable to the Lazarus port in parts, although very probably better than nothing... Note also that many properties are marked as "generated automatically. This means that it is not documented.".

This is the introduction that I found for TJvDBLookupList (the rest is a long list of properties with documentation "generated automatically"...

Quote
1.1.121 TJvDBLookupList Class Component
#JVCLInfo
Use TJvDBLookupList to provide users with a convenient list of lookup items to set a field value using the values of a field in
another dataset. Lookup list boxes usually display values that are a represent a more meaningful description of the actual
field value.
TJvDBLookupList provides a list of lookup items for filling in fields that require data from another dataset. Use
TJvDBLookupList to provide users with a convenient list of lookup items to set a field value using the values of a field in
another dataset. Lookup list boxes usually display values that are a represent a more meaningful description of the actual
field value.
The relationship between field values and the corresponding values in the lookup dataset can be set using the properties
LookupSource ( see page 973), LookupField ( see page 973) and LookupDisplay ( see page 972).
This component provides the following:
• You can select any number of fields to be displayed in the lookup list.
• End-users can incrementally search through the lookup list by directly typing into the control.
This is a great advantage when using lookup tables that contain hundreds of even thousands of records.
• You can perform a lookup on a Query or QBE result. It even incrementally searches on the query
result.
• The component does not have to be bound, or assigned, to a table's field (DataField ( see page 966) and
DataSource ( see page 967) properties) which gives you greater flexibility in using this lookup list for general tasks where a
source table is not involved.
If DataSource ( see page 967) and DataField ( see page 966) properties is set, when a user selects a list item, the
corresponding field value is changed in the underlying dataset.
Summary
Provides a list of lookup items for filling in fields that require data from another dataset.
« Last Edit: November 11, 2023, 04:25:36 pm by wp »

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: DBLookUpCombo question ...
« Reply #12 on: November 11, 2023, 04:09:07 pm »
TRon, that's great!  Is there a doc/manual somewhere that documents these property values?
Other than the link already mentioned I am not aware of another source for additional information.

I assumed that there is a help file when you install these components but their content would most probably not differ from the wiki.

The wiki (for obvious reasons) seem to focus on non standard properties and methods that are specific to the control (assuming that you are familiar with standard properties such as popupmenu, font. etc)

edit: wp was a tiny tad faster than me (and even found an additional source)  :)
« Last Edit: November 11, 2023, 04:18:40 pm by TRon »
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018