[SOLVED] Stringgrid searching and scrolling lazarus / 31-LCL ---------------------------------------------------------------------- JD · 2017-03-07 16:24 Hi there everyone, I have a stringgrid with ID and Names in the first 2 columns. I have a combobox on top of it where I allow the user to search by ID or by Name (actually all searches are done by ID because the ID corresponding to the name is retrieved from the combobox before starting the search). When the ID is found in the grid, the corresponding row is highlighted. The problem is the stringgrid is starting to fill up and sometimes the highlighted row is off-screen and can only be located by scrolling up or down in the grid. How can I set it up so that the stringgrid jumps/scrolls to highlighted row immediately after a matching ID is found? My code is shown below: 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 // Searches for the name or ID of a person in a stringgrid row//// ID and Names are in the first 2 columns (ID - column 0; Names - column 1)// // Search is done on column zero (the ID column)//procedure TfrmMain.spedLookupClick(Sender: TObject);var  intID, intCount: integer;  strParam: string;  iFound: boolean;begin  // Ensure that the Lookup combobox is not empty  if (Trim(cboLookup.Text) <> EmptyStr) then  begin    //    iFound := False;    //    if TryStrToInt(Trim(cboLookup.Text), intID) then      strParam := IntToStr(intID)    else      strParam := IntToStr(Integer(cboLookup.Items.Objects[cboLookup.ItemIndex]));    //    case PageControl1.ActivePage.Caption of      'Services':      begin        //        for intCount := 0 to sgrdServices.RowCount - 1 do          begin            // Search down the ID column            if sgrdServices.Cells[0, intCount] = strParam then            begin            iFound := True;              sgrdServices.Row := intCount;  // select the row where the name or ID was found              Break;            end          end;      end;    // 'Services'    //    if not iFound then      MessageDlg(strIDNomIntrouvable, mtWarning, [mbOK], 0);  end;      // if (Trim(cboLookup.Text) <> EmptyStr) thenend;  Thanks for your contributions JD ---------------------------------------------------------------------- balazsszekely · 2017-03-07 16:46 @JD Did you try to set the TopRow property to intCount? ---------------------------------------------------------------------- wp · 2017-03-07 16:47 Which version are you using? I have reported a similar issue related to smooth scrolling and variable height rows; the bug has been fixed in Laz trunk in Oct last year (http://bugs.freepascal.org/view.php?id=30678). ---------------------------------------------------------------------- JD · 2017-03-07 17:00 Quote from: GetMem on March 07, 2017, 05:46:35 pm@JD Did you try to set the TopRow property to intCount? TopRow seems to work nicely. Thanks ---------------------------------------------------------------------- JD · 2017-03-07 17:00 Quote from: wp on March 07, 2017, 05:47:28 pmWhich version are you using? I have reported a similar issue related to smooth scrolling and variable height rows; the bug has been fixed in Laz trunk in Oct last year (http://bugs.freepascal.org/view.php?id=30678). I'm using Lazarus 1.6/FPC 3.0.0 on win32.