Search code examples
delphifreepascallazaruststringgrid

lazarus grids key-value pair


In the lazarus (and also delphi probably) documentation about grids, we can find the next description for the InsertRow function:

Function InsertRow
    Inserts a row in the grid and sets
    the Key-Value pair. Returns the
    index of the newly inserted row.

What is this key-value pair?


Solution

  • This is related to the TValueListEditor, and not grids in general. The TValueListEditor is similar in appearance to the Delphi Object Inspector. For brevity, I'll refer to it as VLE in the text below.

    TValueListEditor.InsertRow takes three parameters:

    function InsertRow(const KeyName: string; const Value: string; 
      Append: Boolean): Integer;
    

    The keyname parameter is the name of the key (the left column of the VLE). Value is the key value (the right column of the VLE). This is stored in the same manner as the TStrings key=value pairs in the Strings property. For instance, calling it using InsertRow('Testing', '123', False) would store Testing=123.

    Append merely controls whether the new entry is added before or after any already selected item in the VLE. If the VLE is empty, it has no effect.

    For more information, see the Delphi VCL help