DBGRID can help me to undertand what misteke i made lazarus / 16-Databases ---------------------------------------------------------------------- eldonfsr · 2021-09-09 00:59 I have app with dbgrid type datas and also i have EditButton for type information in a column after tye information i executing this code but send me error when i values to selectedindex:=2 here the process 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 TFormPartInf.EBSuplExit(Sender: TObject);Var Tsql:TsqlQuery;begin   Tsql:= TsqlQuery.Create(nil);   Tsql.DataBase := DM.InvMgrCon;   Tsql.Transaction := DM.SQLTInvMgr;   if( (CapSupl = true) and ( EbSupl.Text <>'') ) then begin       tsql.SQL.Text:='select * from suppliers where Addid =:psupid';       tsql.ParamByName('psupid').AsInteger:= StrToInt(EbSupl.Text);       tsql.Open;       if( not Tsql.EOF) then begin           BDPartSupl.edit;           BDPartSupl.FieldByName('SupplierName').AsString:= Tsql.FieldByName('CoName').AsString;           BDPartSupl.FieldByName('Supplierid').AsInteger:= Tsql.FieldByName('AddId').AsInteger;           BDPartSupl.Post;        end else begin           ShowMessage('Supplier not found try another code');           EBSupl.Text:='';           EBSupl.SetFocus;         CapSupl:=false;       end;   end;   if( (CapSupl=true) and (DBGPartsSup.SelectedIndex=0) ) then begin       CapSupl:=false;       EBSupl.Visible:=false;       DBGPartsSup.SelectedIndex:=2; end;end;        I Can assign value if dbgrid dont has focus? and send me to this function of dbgrid 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 function TCustomGrid.GetColumns: TGridColumns;begin  result := FColumns;end;  thanks any help great.. ---------------------------------------------------------------------- balazsszekely · 2021-09-09 06:02 Hi eldonfsr, 1. 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 DBGPartsSup.SelectedIndex := 2;The method DBGrid.SelectedIndex, just selects a particular column in the grid. Take a look at the attached image, the focus is on "ccc", if I press the select button 'ccc description' will be selected. That's it. The questions are: 1. Is your grid populated? 2. Do you have at least two columns? 2. 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 if( not Tsql.EOF) then begin           BDPartSupl.edit;           BDPartSupl.FieldByName('SupplierName').AsString:= Tsql.FieldByName('CoName').AsString;           BDPartSupl.FieldByName('Supplierid').AsInteger:= Tsql.FieldByName('AddId').AsInteger;           BDPartSupl.Post;        end What exactly are you trying to achieve? Loop through the dataset(Tsql) and modify each record for BDPartSupl? Or something else? ---------------------------------------------------------------------- eldonfsr · 2021-09-10 02:53 I wanna update the table to edit on dbgrid  form sqltable get information and update databuffer because is simple manage databuffer than tsql table when edition done i have to update sqltables with new information and the information was change. if( not tsql.Eof) to see if the information typed record exist on table if is true record was found and put information on databuffer   DBPartSupl  this table is controled by dbgrid.            BDPartSupl.edit;            BDPartSupl.FieldByName('SupplierName').AsString:= Tsql.FieldByName('CoName').AsString;            BDPartSupl.FieldByName('Supplierid').AsInteger:= Tsql.FieldByName('AddId').AsInteger;            BDPartSupl.Post;  Thanks For your replay. ---------------------------------------------------------------------- eldonfsr · 2021-09-10 23:48 Yes is populated you can see on image.. ---------------------------------------------------------------------- eldonfsr · 2021-09-11 00:23 Look just eliminate line SelectedIndex:=2 and no send me error but not move to next column.. ---------------------------------------------------------------------- balazsszekely · 2021-09-11 06:20 QuoteLook just eliminate line SelectedIndex:=2 and no send me error but not move to next column..OK. I'm glad it's working. You can simulate a key press, to move to the next column: https://forum.lazaru s.freepascal.org/index.php/topic,56206.msg417707.html#msg417707