<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE feed [
      <!ENTITY lt "&#38;#60;">
      <!ENTITY gt "&#62;">
      <!ENTITY amp "&#38;#38;">
      <!ENTITY apos "&#39;">
      <!ENTITY quot "&#34;">
      <!ENTITY nbsp "&#160;">
      <!ENTITY copy "&#169;">
]>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title type="text">開発ブログ</title>
    <subtitle type="text">MASA Lab softlab-Software Architecture Laboratory</subtitle>
    <updated>2026-04-17T14:48:12+09:00</updated>
    <id>http://softlab.masa-lab.net/modules/d3blog/index.php</id>
    <link rel="alternate" type="text/xhtml" hreflang="ja" href="http://softlab.masa-lab.net/" />
    <link rel="self" type="application/atom+xml" href="http://softlab.masa-lab.net/modules/d3blog/index.php?page=atom" />
    <rights>Copyright &copy; 2008-2019 by MASA-Lab</rights>
    <generator uri="http://softlab.masa-lab.net/">D3BLOG - XOOPS BLOG MODULE</generator>
    <entry>
        <title>LiveBindings の文字列に注意？</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=130" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=130</id>
        <published>2014-11-25T17:03:43+09:00</published>
        <updated>2015-01-17T21:29:19+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">良くありますよね、%表示したい時って。だから LiveBindings の CustomFormat に
Format(&#039;%.0f&#039;, Self.Value*100) + &quot;%&quot;
って書いたのですが、「書式文字列 'Format(... は正しくないか引数の型...</summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>良くありますよね、%表示したい時って。<br />だから LiveBindings の CustomFormat に<br /><pre class="blogCode"><code>
Format(&#039;%.0f&#039;, Self.Value*100) + &quot;%&quot;
</code></pre><br />って書いたのですが、「書式文字列 'Format(... は正しくないか引数の型と一致しません.」というエラーが出てしまいます。<br />いろいろ試してみるのですが、そもそもドキュメントにある例の<br />Format("%d %d", 1, 2)<br />すら動きません。<br /><br />もうなんだか全然わからなくなって、パニックです。<br />ようやくバインディング式の説明で %s というのがあるのを思い出して、% 自体がバインディング式の特殊文字なのだと気が付きました。<br />そこで<br /><pre class="blogCode"><code>
Format(&#039;%%.0f&#039;, Self.Value*100) + &quot;%%&quot;
</code></pre><br />としたらうまくいきました。<br />あぁ疲れた...<br /><br />Delphi XE5</div>]]>
       </content>
    </entry>
    <entry>
        <title>LiveBinding では 列挙型は使えない</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=99" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=99</id>
        <published>2014-09-03T13:59:07+09:00</published>
        <updated>2023-12-25T19:33:44+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">列挙型のプロパティのあるクラスを TCustomAdapterBindSource などでバインドソースにしたのですが、列挙型のプロパティは LiveBindingデザイナに出てきませんでした。仕方がないので、Integer に...</summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>列挙型のプロパティのあるクラスを TCustomAdapterBindSource などでバインドソースにしたのですが、列挙型のプロパティは LiveBindingデザイナに出てきませんでした。<br /><br />仕方がないので、Integer にキャストしたプロパティを作って、そこから値をマップしました。<br /><br />もしかしたら * と Owner を使った技で回避できるかも？<br />と思ってやってみましたが、うまくいきませんでした。<br />そもそも FindField で見つけることができませんね。<br />Object ならアクセスできるのですが... <br /><br /><a href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=105" target="_blank">LiveBindings CustomFormat で * と Self を使う</a></div>]]>
       </content>
    </entry>
    <entry>
        <title>LiveBindings カスタムフォーマット</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=95" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=95</id>
        <published>2014-08-25T21:02:26+09:00</published>
        <updated>2014-11-01T14:18:19+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">LiveBindings のカスタム書式ではいくつかのデフォルトの LiveBinding メソッドが使えますが、これだけではなかなかきついですよね。そんな時には独自のカスタム LiveBinding メソッドを作ること...</summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>LiveBindings のカスタム書式ではいくつかの<a href="http://docwiki.embarcadero.com/RADStudio/XE6/ja/%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE_LiveBinding_%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89" target="_blank">デフォルトの LiveBinding メソッド</a>が使えますが、これだけではなかなかきついですよね。<br />そんな時には独自のカスタム LiveBinding メソッドを作ることができます。<br /><br />決まった書き方で関数を作成してパッケージとしてインストールする必要がありますが...<br /><br /><a href="http://docwiki.embarcadero.com/RADStudio/XE6/ja/%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0_LiveBinding_%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89%E3%81%AE%E4%BD%9C%E6%88%90" target="_blank">カスタム LiveBinding メソッドの作成</a><br /><br />作成したカスタムメソッドがデザイン画面では使えるのに、実行時にエラーが発生する場合には uses に追加すれば使えるようになると思います。</div>]]>
       </content>
    </entry>
    <entry>
        <title>TListBindSourceAdapter を使った時の バインディング式</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=89" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=89</id>
        <published>2014-07-02T20:40:00+09:00</published>
        <updated>2015-01-17T21:40:05+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">TListBindSourceAdapter などを使ってオブジェクトをバインドして使うときにTBindExpression の SourceExpression で、単純にフィールド名を書くとエラーになってしまいます。
FieldName.Value
と書く必要...</summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>TListBindSourceAdapter などを使ってオブジェクトをバインドして使うときに<br /><br />TBindExpression の SourceExpression で、単純にフィールド名を書くとエラーになってしまいます。<br /><pre class="blogCode"><code>
FieldName.Value
</code></pre><br />と書く必要があるんですね。<br /><br />LiveBindings 書式設定式に書けるメソッドには<br />Format(<書式文字列>, <引数 1>, <引数 2>, …)<br />IfThen(<条件>, <真の場合の値>, <偽の場合の値>)<br />Lookup(<スコープ ルックアップ>, <キー フィールド>, <キー値>, <結果フィールド>)<br /><br />など、その他使える式は以下にあります。<br /><br /><a href="http://docwiki.embarcadero.com/RADStudio/XE6/ja/%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE_LiveBinding_%E3%83%A1%E3%82%BD%E3%83%83%E3%83%89" target="_blank">デフォルトの LiveBinding メソッド</a><br /><a href="http://docwiki.embarcadero.com/RADStudio/XE6/en/Default_LiveBindings_Methods" rel="external">http://docwiki.embarcadero.com/RADStudio/XE6/en/Default_LiveBindings_Methods</a></div>]]>
       </content>
    </entry>
    <entry>
        <title>LiveBinding ComboBox の初期値を設定する</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=88" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=88</id>
        <published>2014-06-30T21:12:49+09:00</published>
        <updated>2023-12-25T20:03:58+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">BindSource に対して Locate を使う？Locate(KeyField, KeyValue)この時 LiveBindings の設定はComboBoxのSynch  BindSourceの *ComboBoxのItem.Text </summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>BindSource に対して Locate を使う？<br />Locate(KeyField, KeyValue)<br /><br />この時 LiveBindings の設定は<br />ComboBoxのSynch <-> BindSourceの *<br />ComboBoxのItem.Text <- BindSourceの 表示フィールド<br />となっていなければならない<br /><br />Delphi XE5</div>]]>
       </content>
    </entry>
    <entry>
        <title>Delphi LiveBindings クラスからバインドする</title>
        <link rel="alternate" type="text/xhtml" href="http://softlab.masa-lab.net/modules/d3blog/details.php?bid=85" />
        <id>http://softlab.masa-lab.net/modules/d3blog/details.php?bid=85</id>
        <published>2014-06-28T21:30:00+09:00</published>
        <updated>2023-12-25T19:41:00+09:00</updated>
        <category term="LiveBindings" label="LiveBindings" />
        <author>
            <name>masa</name>
        </author>
        <summary type="html" xml:base="http://softlab.masa-lab.net/" xml:lang="ja">クラスからバインドして表示するTAdapterBindSource と TDataGeneratorAdapter(1) まずは二つを配置(2) AdapterBindSource の Adapter プロパティに DataGeneratorAdapter をセット(3) AdapterBindSource の OnCreateAdapter イベ...</summary>
       <content type="html" xml:lang="ja" xml:base="http://softlab.masa-lab.net/">
<![CDATA[<div>クラスからバインドして表示する<br /><br />TAdapterBindSource と TDataGeneratorAdapter<br /><br />(1) まずは二つを配置<br />(2) AdapterBindSource の Adapter プロパティに DataGeneratorAdapter をセット<br /><br />(3) AdapterBindSource の OnCreateAdapter イベントで<br />TObjectBindSourceAdapter<T><br />または<br />TListBindSourceAdapter<T><br />を生成する<br /><br /><pre class="blogCode"><code>
procedure TMain.AdapterBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
var
  LEmployee: TEmployee;
begin
  LEmployee := TEmployee.Create(&#039;John&#039;, &#039;Anders&#039;, 26, StrToDate(&#039;10/10/2011&#039;), &#039;Developer&#039;, &#039;Adrian Hermann&#039;);
  ABindSourceAdapter := TObjectBindSourceAdapter&lt;TEmployee&gt;.Create(Self, LEmployee);
end;
</code></pre><br /><br />または<br /><br /><pre class="blogCode"><code>
procedure TMain.AdapterBindSource1CreateAdapter(Sender: TObject; var ABindSourceAdapter: TBindSourceAdapter);
var
  LList: TObjectList&lt;TEmployee&gt;;
begin
  LList := TObjectList&lt;TEmployee&gt;.Create;
  LList.Add(TEmployee.Create(&#039;John&#039;, &#039;Anders&#039;, 26, StrToDate(&#039;10/10/2011&#039;), &#039;Developer&#039;, &#039;Adrian Hermann&#039;));
  ABindSourceAdapter := TListBindSourceAdapter&lt;TEmployee&gt;.Create(Self, LList, True);
end;
</code></pre><br /><br />クラスにバインドできるってうれしい<br /><br /><br /><a href="http://docwiki.embarcadero.com/RADStudio/XE3/ja/%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB%EF%BC%9ATAdapterBindSource_%E3%81%A8%EF%BC%BBLiveBinding_%E3%83%87%E3%82%B6%E3%82%A4%E3%83%8A%EF%BC%BD%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B" rel="external">http://docwiki.embarcadero.com/RADStudio/XE3/ja/%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB%EF%BC%9ATAdapterBindSource_%E3%81%A8%EF%BC%BBLiveBinding_%E3%83%87%E3%82%B6%E3%82%A4%E3%83%8A%EF%BC%BD%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B</a></div>]]>
       </content>
    </entry>
</feed>