RecordGridのヘッダー列のコピー

【ご質問】
レコードグリッドで特定の行を選択しコピーした際、ヘッダー列名も合わせて
コピーすることはできますでしょうか。

【回答】
RecordGridCopyの”execute”メソッドを改変することで実現可能となります。

{curl 6.0,7.0,8.0 applet}
{curl-file-attributes character-encoding = “shift-jis”}

{import * from CURL.DESKTOP.CLIPBOARD}

{define-class public MyRecordGridCopy {inherits RecordGridCopy}
  {constructor public {default …}   
    {construct-super …}
  }
   
  {method protected open {execute}:void 
    {super.execute}

    let constant line-delimiter:char = ‘\n’
    let constant cell-delimiter:char = ‘\t’
   
    let (value:String, valid?:bool) = {{Clipboard.get-system-clipboard}.get-string}
    let new-string:StringBuf = {StringBuf}
    {for r:RecordGridColumn in self.context.columns do
        {new-string.concat r.field-name}
        {new-string.append cell-delimiter}
    }
    {new-string.remove (new-string.size – 1), error-if-missing? = false}
    {new-string.append line-delimiter}
    {new-string.concat value}

    {{Clipboard.get-system-clipboard}.set-string new-string}
  }
}

{define-class public MyRecordGrid {inherits RecordGrid}
  {constructor public {default …}
    {construct-super …}
  }
  {method public open {create-command name:String}:#Command
    {return
        {switch name
         case “copy”  do {MyRecordGridCopy self}
         else
            {super.create-command name}
        }
    }
  }
}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField “First”, domain = String},
            {RecordField “Last”, domain = String},
            {RecordField “Age”, domain = int}
        },
        {RecordData First = “John”, Last = “Smith”, Age = 25},
        {RecordData First = “Jane”, Last = “Smith”, Age = 29},
        {RecordData First = “Jane”, Last = “Jones”, Age = 28}
    }
}
{let rg:MyRecordGrid = {MyRecordGrid
                           record-source = people,
                           height = 13cm,
                           automatic-columns? = false,
                           {RecordGridColumn  “First”},
                           {RecordGridColumn  “Last”},
                           {RecordGridColumn  “Age”}
                       }
}
{value
    rg
}