Solved: TDBGrid keyUp,KeyDown event lazarus / 16-Databases ---------------------------------------------------------------------- xaver13 · 2017-11-06 10:01 hello, I am using TdbGrid and I want to show some values from it  in another fields, when user clicks on it. The solution is simple I used a Query named Query1 and a Datasource and a DBGrid1CellClick event like this: 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 TFormWallet.DBGrid1CellClick(Column: TColumn);begin     if query1.FieldByName('col_2').Value <> null then     edtCol_2.Text:=Query1.FieldByName('col_2').Value else edtCol_2.Text:='' ;     if query1.FieldByName('col_10').Value <> null then     edtCol_10.Text:=Query1.FieldByName('col_10').Value else edtCol_10.Text:='';     if query1.FieldByName('col_14').Value <> null then     edtCol_14.Text:=Query1.FieldByName('col_14').Value else edtCol_14.Text:=''; end; It works fine, but the problem is, when I want to do the same when user uses keyboard, when I use KeyDownEvent simillar DBGridClick event like this 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 TFormWallet.DBGrid1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);begin    //   query1.RecNo:=query1.RecNo+1 ;     if query1.FieldByName('col_2').Value <> null then     edtCol_2.Text:=Query1.FieldByName('col_2').Value else edtCol_2.Text:='' ;     if query1.FieldByName('col_10').Value <> null then     edtCol_10.Text:=Query1.FieldByName('col_10').Value else edtCol_10.Text:='';     if query1.FieldByName('col_14').Value <> null then     edtCol_14.Text:=Query1.FieldByName('col_14').Value else edtCol_14.Text:='';     // query1.RecNo:=query1.RecNo-1;end;  record is the previous, and that is the problem,  I tried the solution with RecNo modification (commented here, but it is very stupid), even if I want to write KeyUpEvent too  PLease do you know better solution? Thank you very much for help. ---------------------------------------------------------------------- rvk · 2017-11-06 10:06 This would depend on what key the user clicks. But I don't think it's a good idea (and even what you want) to do it like you do. Isn't it better to use TDBEdit instead of TEdit? Of did you use TEdit (over TDBEdit) for a reason? (With TDBEdit the edit-field will be automatically filled with your desired value from the database.) PS. you can eliminate the if's if you do it like this: 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 edtCol_2.Text:=Query1.FieldByName('col_2').asString;(asString will give an empty string if the field is Null ---------------------------------------------------------------------- xaver13 · 2017-11-06 12:49 Thank you very much for help! I did not know about TDBedit.