Recent

Author Topic: [SOLVED] DBGrids and DBLookupComboBoxes  (Read 1573 times)

guest48180

  • Guest
[SOLVED] DBGrids and DBLookupComboBoxes
« on: September 28, 2019, 11:41:46 am »
I use a DBLookupComboBox in a DBGrid. And taking that step has caused me nothing but headaches!

I can't make a selection from the DBLookup and make it stick to the cell. And I can't add to the DBLookup either.

I've messed with this for three days and I'm no closer now than I was when I started. I found a couple Delphi tuts on youtube, but they were useless. And searching for info online is a waste of time.

I've tried OnColExit with no luck. I also tried OnEditingDone with no luck. I cant figure out when/where I need to pass off the DBLookup's text to the column cell. I just don't get it. I'd rather slide down a pole of razorblades and land in a pool of alcohol as come here and ask for help, but this dbgrid/dblookupcombobox sorcery is beyond me.

tonyw

  • Sr. Member
  • ****
  • Posts: 321
    • MWA Software
Re: DBGrids and DBLookupComboBoxes
« Reply #1 on: September 28, 2019, 01:05:29 pm »
If you are using IBX, then the TIBDynamicGrid component (TDBGrid descendent) has this as a built in capability. You can see how it is done in the "employee" example: look at the column properties for the "JOB_COUNTRY" field. The DBLookupProperties include a ListSource and ListField just as you would in a TDBLookupComboBox.

The IBX User Guide includes more information.

If you are not using IBX, then you can always look at the source code to see how it's done.

guest48180

  • Guest
Re: DBGrids and DBLookupComboBoxes
« Reply #2 on: September 28, 2019, 01:18:44 pm »
I don't use IBX, and I can't find the example you mentioned. I thought it'd be in the examples folder, but I don't see it there.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: DBGrids and DBLookupComboBoxes
« Reply #3 on: September 28, 2019, 01:45:47 pm »
Why do you stuff the lookup into the grid? Lookup of data values from another table is solved in a more general way by using lookup fields. Create a persistent field lookup field. Using a lookup field in a DBGrid column automatically applies a lookup combobox.

These links are for Delphi, but Lazarus should work in the same way:
http://docwiki.embarcadero.com/RADStudio/Rio/en/Defining_a_Lookup_Field. This automatically displays a lookup combobox in the grid.
https://www.tek-tips.com/faqs.cfm?fid=1213

guest48180

  • Guest
Re: DBGrids and DBLookupComboBoxes
« Reply #4 on: September 28, 2019, 02:00:34 pm »
Why do you stuff the lookup into the grid?

Because all I've found has taught me to do what you see in the zip file. Not to mention that's where I need it. And several more. Also some checkboxes. I'm trying, man, even if it's wrong. And on that note, I appreciate the links and will do my best with them. Thank you very much for helping me.

 

TinyPortal © 2005-2018