469,357 Members | 1,565 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,357 developers. It's quick & easy.

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.
Jul 19 '10 #1
5 2995
iohos
45
Expand|Select|Wrap|Line Numbers
  1. procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
  2.  
  3.   Field: TField; State: TGridDrawState);
  4.  
  5. begin
  6.  
  7.   if (gdFocused in State) then
  8.  
  9.   begin
  10.  
  11.   if (Field.FieldName = DBLookupCombo1.DataField) then
  12.  
  13.   begin
  14.  
  15.   DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
  16.  
  17.   DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
  18.  
  19.   DBLookupCombo1.Width := Rect.Right - Rect.Left;
  20.  
  21.   { DBLookupCombo1.Height := Rect.Bottom - Rect.Top; }
  22.  
  23.   DBLookupCombo1.Visible := True;
  24.  
  25.   end;
  26.  
  27.   end;
  28.  
  29. end;
  30.  
hope dis helps
Jul 25 '10 #2
Jyoti Ballabh
115 100+
@iohos
the problem persists, after a repetitious use of the algorithm the grid "shows in the same place where it was first envoked".
Aug 1 '10 #3
iohos
45
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.
Aug 1 '10 #4
Jyoti Ballabh
115 100+
The parentheses in the second last line of the program may not be required.
Aug 1 '10 #5
iohos
45
yup, can do without it.
Aug 1 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Kenneth Keeley | last post: by
4 posts views Thread by Paul | last post: by
1 post views Thread by Vijay Kerji | last post: by
2 posts views Thread by Mike Collins | last post: by
5 posts views Thread by jung_h_park | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.