Recent

Author Topic: TRxDbGrid with lookup field  (Read 19176 times)

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
RE: news ?
« Reply #15 on: October 31, 2007, 10:45:36 am »
use OnDrawCell there's a TRect argument for the cell position, just use it's left/right/bottom/top to set the comboboxes.

I currently use normal comboboxes which I manage myself (eg: fill etc.)

alexs

  • New Member
  • *
  • Posts: 19
    • http://alexs75.narod.ru/
RE: news ?
« Reply #16 on: November 06, 2007, 12:25:38 pm »
Hi
i'm make in RxDBGrid new editor for lookup fields

nelson777

  • Jr. Member
  • **
  • Posts: 68
    • http://www.aocontrario.com
RE: news ?
« Reply #17 on: November 09, 2007, 02:10:44 am »
Almindor: I tried that and all I got was a bunch of crazy combos jumping on the dbgrid :)
Let me get this right: u use combo.BoundsRect := Rect in OnDrawColumnCell event and Editor := combo in the OnSelectEditor event ? is that it ? or there´s something else ?

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
RE: news ?
« Reply #18 on: November 09, 2007, 11:40:58 am »
I use this:
Code: [Select]

  if gdFocused in State then begin

    case DataCol of // col # need to be the one where you want to display the combo

      0 : with aControl do begin // a control is just some Control like TComboBox placed on form which is invisible ATM.

             Left := aRect.Left + aDBGrid.Left + 2; // windows specific, to make it look 100% fitting

             Top := aRect.Top + aDBGrid.Top + 1;

             Width := aRect.Right - aRect.Left;

             Height := aRect.Bottom - aRect.Top;

             Visible := True;

           end;
        // if you had more of them, meke sure to make the OTHER ones invisible
      else begin
        AllControls.Visible := False // quasi-code -- make all those controls invisible again since we're on different cols
      end;
    end;
  end;

nelson777

  • Jr. Member
  • **
  • Posts: 68
    • http://www.aocontrario.com
RE: news ?
« Reply #19 on: November 09, 2007, 05:02:39 pm »
Almindor: thanx! u helped me a lot. Yet, I adapted your code a bit. Maybe it helps you too.

in OnDrawColumnCell:

  if (gdFocused in State) and (DataCol = 3) then // whatever column number
      combo.BoundsRect := Rect;

in OnSelectEditor:

  if (Column.DesignIndex = 3) then // whatever column number
      Editor := combo;

What do u think ? yet using this approach, one of the cells of the column containing the combo appears blank until I post the record. Sometimes the first, sometimes the last. I couldn´t find whatever is causing this.

hccadre@gmail.com

  • Newbie
  • Posts: 2
Re: TRxDbGrid with lookup field
« Reply #20 on: July 14, 2021, 10:26:44 pm »
Hello alex

I am using lazarus v2.012 and rxnew 3.3.5.231.

In a form I have placed a RxDBGrid component with a lookup column, I want to know if it is possible search on the values ​​of this column as the user types, just like the TRxDBLookupCombo component does.

Now when I run the project, position the cursor on the lookup column field and write some value nothing happens, and I would like to locate the values ​​that contain the characters that the user types.

Thanks in advance.

 

TinyPortal © 2005-2018