how to fix delphi dbgrid dropdown list problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clear1140
    New Member
    • Sep 2007
    • 13

    how to fix delphi dbgrid dropdown list problem

    I have a DBgrid and one column is a look up to a table. When the the drop down list is envoked and when the form is being resized or moved around, the list will still be shown at the same spot where it first was envoked. I don't know what seems to be the problem.
  • iohos
    Banned
    New Member
    • Jul 2010
    • 45

    #2
    Code:
    procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
    
      Field: TField; State: TGridDrawState);
    
    begin
    
      if (gdFocused in State) then
    
      begin
    
      if (Field.FieldName = DBLookupCombo1.DataField) then
    
      begin
    
      DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
    
      DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
    
      DBLookupCombo1.Width := Rect.Right - Rect.Left;
    
      { DBLookupCombo1.Height := Rect.Bottom - Rect.Top; }
    
      DBLookupCombo1.Visible := True;
    
      end;
    
      end;
    
    end;
    hope dis helps
    Last edited by gits; Aug 1 '10, 09:46 PM. Reason: added code tags

    Comment

    • Jyoti Ballabh
      Banned
      New Member
      • Jul 2010
      • 115

      #3
      Originally posted by iohos
      procedure TForm1.DBGrid1D rawDataCell(Sen der: TObject; const Rect: TRect;

      Field: TField; State: TGridDrawState) ;

      begin

      if (gdFocused in State) then

      begin

      if (Field.FieldNam e = DBLookupCombo1. DataField) then

      begin

      DBLookupCombo1. Left := Rect.Left + DBGrid1.Left;

      DBLookupCombo1. Top := Rect.Top + DBGrid1.top;

      DBLookupCombo1. Width := Rect.Right - Rect.Left;

      { DBLookupCombo1. Height := Rect.Bottom - Rect.Top; }

      DBLookupCombo1. Visible := True;

      end;

      end;

      end;

      hope dis helps
      the problem persists, after a repetitious use of the algorithm the grid "shows in the same place where it was first envoked".

      Comment

      • iohos
        Banned
        New Member
        • Jul 2010
        • 45

        #4
        that's impossible, spettro. I ran this using some random data (the rooster of the New England Patriots). The drop down list worked just fine even after making countless edits.

        Comment

        • Jyoti Ballabh
          Banned
          New Member
          • Jul 2010
          • 115

          #5
          The parentheses in the second last line of the program may not be required.

          Comment

          • iohos
            Banned
            New Member
            • Jul 2010
            • 45

            #6
            yup, can do without it.

            Comment

            Working...