(solved) Horizontal scroll event into dbgrid lazarus / 16-Databases ---------------------------------------------------------------------- xinyiman · 2019-02-11 21:41 Hi guys, I have a problem. In a dbgrid to the onselecteditor of a particular column I make a combobox appear to manipulate the data. Only when I move horizontally with the scrollbar also moves the combobox. I would like to intercept the horizontal scroll event to hide my combobox. Ideas? Thank you ---------------------------------------------------------------------- daveinhull · 2019-02-11 21:47 Hi, use oncolexit to hide the control ---------------------------------------------------------------------- daveinhull · 2019-02-11 21:57 Hi Some more code that might help: The the grid draws I use the DrawColumnCell event to (this is an example of using DateTimePicker, but it works with other controls Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);begin  if (gdFocused in State) then  begin    if (Column.Field.FieldName = 'FuelDate') then    with DateTimePicker1 do    begin      Date := DBGrid1.SelectedField.AsDateTime;      Left := Rect.Left + DBGrid1.Left + 1;      Top := Rect.Top + DBGrid1.Top + 1;      Width := Rect.Right - Rect.Left + 1;      Height := Rect.Bottom - Rect.Top + 1;      Visible := True;      DateTimePicker1.SetFocus;      DBGrid1.DataSource.Edit; The on ColExit Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DBGrid1ColExit(Sender: TObject);begin   if DBGrid1.SelectedField.FieldName = 'FuelDate' then  begin    if DBGrid1.DataSource.State in [dsEdit, dsInsert] then      DBGrid1.SelectedField.value := DateTimePicker1.Date;    DateTimePicker1.Visible := False  end; And in the DatTimePicker, I catch certain keys to pass back to the grid Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.DateTimePicker1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin  if (Key = 9) or (Key = 38) or (Key = 40) then  begin    DBGrid1.SetFocus;    SendMessage(DBGrid1.Handle, WM_KeyDown, Key, 0);  endend; Might be a little different that you are using but it might give you some clues. Dave ---------------------------------------------------------------------- xinyiman · 2019-02-11 22:54 I do not understand how it works. I move with the scrollbar to the right or left not with the keydown. ---------------------------------------------------------------------- daveinhull · 2019-02-11 23:08 Sorry, misread your post. However, wouldn't logic say that if you are just scrolling with the scroll bar, then the same field remain selected and so the overplayed control should also remain visible until you leave the column? ---------------------------------------------------------------------- xinyiman · 2019-02-11 23:20 First image is ok, but second is incorrect because i move scrollbar to right ---------------------------------------------------------------------- daveinhull · 2019-02-12 06:24 Ok, so if you use OnDrawColumnCell and check the field name to the one you want then it should work, see my example [edit] and use the rect provided for the cell to position your control. ---------------------------------------------------------------------- xinyiman · 2019-02-13 07:35 Thank you. Run correctly.