Recent

Author Topic: [SOLVED] Controlling the behavior - JVCLLaz - JvDBLookUpCombo?  (Read 5884 times)

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #15 on: March 27, 2024, 09:45:56 pm »
Well, the issue is the width of the JvDBLookUpCombo itself on the form.
Just for a test I defined in my Appointments unit OnShow like the JvDBLaz example:
Code: Pascal  [Select][+][-]
  1.   DbfCntks.FieldByName('CNTKLNAME').DisplayWidth:= 15;
  2.   DbfCntks.FieldByName('CNTKFNAME').DisplayWidth:= 15;
  3.   DbfCntks.FieldByName('CNTKMI').DisplayWidth:= 1;
  4.  


  But not an issue it's the way it's designed.  Experimenting, the drop-down can't widen any wider than the width of the component placed on the form.  For example, if you define the display widths for Contact Last Name and First Name to 15 chars. each and Contact Mi to 1 char. as above and put the JvDBLookUpCombo on the form and widen to display the width a bit larger than 20 chars. the drop-down can't widen itself to accommodate a lastname+firstname+mi that adds up to say LastName+Firstname+Mi =27 ttl. chars. It's not going to display lastname firstname mi in columns nice and neat because your restricted to the combobox's width, it can't grow to adapt when it drops down.  So, for some names that have long last names, first name and mi that add up to 29 chars. your going to have to have a really long dropdowncombo.  I'm going back to defining my dropdowns that drop-down more that 2 fields to IsDelimited vs IsFixed and the users probably  aren't going to care, they'll just accept it the way it is! LoL

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #16 on: March 27, 2024, 09:52:37 pm »
Here's a picture, this ain't gonna cut it.  Lastname, Firstname and MI were predefined display widths of 15, 15, 1.  Here's what you get. The combo is showing the lastname more that 15 chars.  ????

rvk

  • Hero Member
  • *****
  • Posts: 6199
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #17 on: March 27, 2024, 10:38:09 pm »
Here's a picture, this ain't gonna cut it.  Lastname, Firstname and MI were predefined display widths of 15, 15, 1.  Here's what you get. The combo is showing the lastname more that 15 chars.  ????
Just curious... what is you dpi setting of your display?

And what happens if you just set displaywith of CNTKLNAME to 5?

Displaywidth should be characters but I wonder if setting it to 5 will also cut it to 5 there.
Or perhaps your dpi isn't 96 (100%) and there is she weird conversion.

https://www.freepascal.org/docs-html/fcl/db/tfield.displaywidth.html

wp

  • Hero Member
  • *****
  • Posts: 12013
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #18 on: March 27, 2024, 10:43:40 pm »
Also, what is TBufDataSet? Also, TMemDataSet? TBufDataSet appears to be a temporary data holder correct?
TBufDataset is an in-memory dataset, no server required, no external dlls etc. You can use it as a standalone database providing, or as a local buffer for data in a remote database. It is relatively complete, except for SQL (there is ZMSQL in OPM which provides an SQL-capable descendant).

TMemDataset is similar to TBufDataset, but more lightweight, and lacks some features (no indexes, no filtering, no Locate functionality).

See: https://wiki.freepascal.org/How_to_write_in-memory_database_applications_in_Lazarus/FPC

Is the Lazarus Handbook a good buy?
In my opinion, the Lazarus Handbook is not a good read for absolute beginners. But since you have some experience, yes, I guess it would be good for you. Have a look at blaisepascal site (https://www.blaisepascalmagazine.eu/en/product/lazarus-handbook-pocket/), you can find the contents listing atm, sometimes they also show some sample chapters. But, since your question is about JVCL, note that the component chapters in the Lazarus Handbook cover only the components coming with Lazarus, third-party components are not the subject of this book.

Experimenting, the drop-down can't widen any wider than the width of the component placed on the form.
Did you play with the DropdownWidth property? You can use it to adjust the width of the dropdown independently of the width of the combobox.

Lastname, Firstname and MI were predefined display widths of 15, 15, 1.  Here's what you get. The combo is showing the lastname more that 15 chars.  ????
Please prepare a sample project similar to the JVCL one to demonstrate the issue. It is much easier to find a bug in the component or an error in the user's project having something to feed the compiler and debugger with.

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #19 on: March 28, 2024, 02:06:52 pm »
Okay, thank you WP/RVK.  I'm going to spend some more time experimenting with your suggestions this morning.  I'll get back to you in a bit.

Take care friends...

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #20 on: March 28, 2024, 02:18:12 pm »
RVK, my monitor is set to 1920 x 1080. It will allow higher setting but going to play around with the display widths a bit.

rvk

  • Hero Member
  • *****
  • Posts: 6199
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #21 on: March 28, 2024, 02:35:41 pm »
RVK, my monitor is set to 1920 x 1080. It will allow higher setting but going to play around with the display widths a bit.
I actually mean the dpi setting, not the resolution.
Normally the dpi setting is 96 dpi (dots per inch).
You can check this (on Windows) by using right click on the desktop and choosing display setting.
What is under Scale and layout the size of the text? 100% ??

You can also check this with ShowMessage(Screen.PixelsPerInch.ToString);
It should say 96. If it's anything else that could interfere with some components (expecting a dpi of 96).
(They should work correct but in this instance that could be the cause)

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #22 on: March 28, 2024, 06:09:27 pm »
RVK, thanks... You and WP helped a lot in understanding how this component works.  Expermenting with the different settings, check the image capture I just made.  This looks good. I have other forms that the JvDBLoopUpCombo isn't displaying the 2nd or 3rd fields in the drop-down to fix these.  The DropDownWidth was the solution along with playing with the 3 dropdown fields displaywidths.

RVK, checked my display settings (Win11) but doesn't actually show DPI. Display settings in Win11 are Scale, Display resolution, Orientation, Multiple Displays, Advanced display, Graphics & Help. None of these give you the dots/inch. But, not an issue... Thanks to the both of you!
 

wp

  • Hero Member
  • *****
  • Posts: 12013
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #23 on: March 28, 2024, 08:29:28 pm »
I have other forms that the JvDBLoopUpCombo isn't displaying the 2nd or 3rd fields in the drop-down to fix these.
As I wrote above, the DisplayWidth specified for a field is interpreted by TJvDBLookupCombo as the width of the same count of 'M' characters. This is required because nowadays fonts have non-uniform character widths; otherwise the column edge would be jagged. Since 'M' is a relatively wide character but other characters are usually much narrower ('i', 'j', 'l', 'r') the DisplayWidth may appear much wider than you anticipate for your real field values. Please repeat your tests after switching the JvDBLookupCombo's font to Courier or another non-proportional font. Specifiying DisplayWidth as count of characters today is not a good measure any more.

Look at the attached screenshots taken from the project in the JVCL examples folder: The first one, jvdbcombo-default.png, was taken with the Lazarus default font. The second one, jvdbcombo-courier.png, was taken with 'Courier New' for the combo's font. See that now the 1st column width defined by the 'City' field's DisplayWidth of 10 is exactly filled in case of the 10-character string 'Marseilles'.
« Last Edit: March 29, 2024, 01:08:23 pm by wp »

rvk

  • Hero Member
  • *****
  • Posts: 6199
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #24 on: March 29, 2024, 08:31:48 am »
Or change London into MMMMMMMMMM (10x M)  ;)

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #25 on: March 29, 2024, 04:55:21 pm »
Okay, thanks.  That last screenshot I made, I was experimenting with the Displaywidths as below my last mod.  But, used the a DropDownWidth=250 to get what I wanted. The 8, 6, 2 are M's.  So, I'll experiment some more with both. 

Code: Pascal  [Select][+][-]
  1.   DbfCntks.FieldByName('CNTKLNAME').DisplayWidth:= 8;
  2.   DbfCntks.FieldByName('CNTKFNAME').DisplayWidth:= 6;
  3.   DbfCntks.FieldByName('CNTKMI').DisplayWidth:= 2;
  4.  

When I first started using JVDbLookUpCombo, I was using it for looking up State & Countries. Basically I had no issue with just 2 fields by setting the AutoSize to True and the RightTrimmedLookUp to True.  A bit of long country names, i.e. United States of America, part of that I can adjust a bit with the DisplayWidths and the DropDownWidth...

Just thinking, could the Property help for JvDBLookUpCombo properties that you see at the bottom of the Properties-Object Inspector be modified by you two so that what I've learned from both you, is included for anyone putting a JvDBLoopUpCombo on a form!!!!

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Controlling the behavior - JVCLLaz - JvDBLookUpCombo?
« Reply #26 on: April 03, 2024, 05:00:37 pm »
WP/RVK, fixed all my forms that I'm using JvDBLoopUpCombo's but a strange issue on 2.  On my Proposals form which is using Clients, Contacts, States, Countries, Priorities tables.  Thought this issue was maybe an index because of a one to many relation - Clients and Contacts but have a disappearing act going on even with a lookup for the Priority, i.e. Good, Non-Profitable, Challenge.  Testing I can create a proposal and select a the main contact for the client and select a Priority of Good.  Save it.  but if I move off the Proposal record via the DBGrid above or add a new Proposal and come back later to a previous.  The Contact Last Name is empty and so is the Priority but both are saved in the Proposal table. You can reselect the Priority, it's there.  If I Save/Post it disappears from the JvDBLookUp component on the form. But this doesn't happen with States, Countries, Status. Just Contact and Priority JvDBLookup's.  I tried just deleting those 2 and rebuild them. All the properties for all of these are the same, except for their Display widths because they are different widths.  Just checking with you to see if you might know more than I what's going on ...

 

TinyPortal © 2005-2018