ValueListEditor.LoadFromCsvFile lazarus / 31-LCL ---------------------------------------------------------------------- kitjackson · 2021-06-07 02:32 Lazarus 2.0.12 Fpc 3.2.2 There seems to be a problem with ValueListEditor.LoadFromCsvFile. When ValueListEditor is the first component in tab order (or the only component on the form which can take the focus) the first value in the key, value pair is lost during LoadFromCsvFile.  See project below. The workaround is to put another component on the form which can take the focus and set the new component to have TabOrder 0 or set property TabStop to false on the ValueListEditor. Is this a feature or a bug? 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 object Form1: TForm1  Left = 251  Height = 240  Top = 132  Width = 320  Caption = 'Form1'  ClientHeight = 240  ClientWidth = 320  LCLVersion = '2.0.12.0'  object SpeedButton1: TSpeedButton    Left = 57    Height = 22    Top = 29    Width = 33    Caption = 'Save'    OnClick = SpeedButton1Click  end  object SpeedButton2: TSpeedButton    Left = 154    Height = 22    Top = 26    Width = 33    Caption = 'Open'    OnClick = SpeedButton2Click  end  object ValueListEditor1: TValueListEditor    Left = 60    Height = 100    Top = 72    Width = 200    FixedCols = 0    RowCount = 4    TabOrder = 0    Strings.Strings = (      'One='      'Two='      'Three='    )    ColWidths = (      64      132    )  endend unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, ValEdit; type   { TForm1 }   TForm1 = class(TForm)    SpeedButton1: TSpeedButton;    SpeedButton2: TSpeedButton;    ValueListEditor1: TValueListEditor;    procedure SpeedButton1Click(Sender: TObject);    procedure SpeedButton2Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.SpeedButton1Click(Sender: TObject);begin  ValueListEditor1.SaveToCsvFile('test.csv');end; procedure TForm1.SpeedButton2Click(Sender: TObject);begin  ValueListEditor1.LoadFromCsvFile('test.csv');end; end. [Edited to add code tags - please see How to use the Forums.] ---------------------------------------------------------------------- Bart · 2021-06-07 09:20 Most likely a bug. Another workaroud is to remove goEdit (?) form the ValuListEditor's Options property. The problem is the fact tha an active Editor is shown, and this plays havoc with the ValueListEditor. If you study it's code you can see multiple attempts to fix that. Apparently not all is covered (sigh). Please rettest with trunk before you file a bugreport. Also, if you file a bugreport, attach a minimal test case, so strip everything away that does not have any influence on the bug in quenstion. Bart ---------------------------------------------------------------------- wp · 2021-06-07 10:24 I think it does not make sense to have editing ON during csv import because the cell which is edited may not exist any more after the import. Therefore I added 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   EditorMode := false; immediately after the "begin" of "TCustomStringGrid.LoadFromCSVStream", and this fixed the issue for me. P.S. I am attaching the code of the first post in compilable form.