とりこらぼ。

Learn from yesterday,
live for today,
hope for tomorrow.

目次

Blog 利用状況

ニュース

プロフィール

  • 名前:とりこびと
    とるに足らない人間です。

  • Wankuma MVP
    for '平々凡々'

Web Site

  • Memo(Of T)

もうひとつの Blog

広告っぽい

書庫

日記カテゴリ

データバインディングのおべんきょ。その10。

データバインディングのおべんきょ。その9。

前回までのあらすじ

反映されていませんが、何か?

でしたね。ええ、書きなぐっていますとも。Text プロパティが変更されたのに Name プロパティに反映されませんでした。とっても切ないです。世の中切ないことばかりです。

ちゃっちゅっちょっと調べてきました。犯人は、お前↓だ!!

MSDN:Binding クラス (System.Windows.Forms)(http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.binding(VS.80).aspx)

っていうか、自分が使おうとするクラスはちゃんとお勉強しておきましょうね。orz

今回の原因はこれ↓でした。

MSDN:Binding.DataSourceUpdateMode プロパティ(http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.binding.datasourceupdatemode(VS.80).aspx)

プロパティは、バインドされたコントロール プロパティの変更がデータ ソースにいつ反映されるかを設定できます。このプロパティの型は

MSDN:DataSourceUpdateMode 列挙体(http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.datasourceupdatemode(VS.80).aspx)

です。DataSourceUpdateMode プロパティの既定値は OnValidation ですのでデータソースへの変更の反映のタイミングは

コントロール プロパティが検証されると、データ ソースが更新されます。

ですね。プロパティの変更のタイミングとは違うということです。

これをプロパティの変更のタイミングに更新されるように前回のコードを以下のように変更します。

Imports System
Imports System.Windows.Forms


Public Class Form1

    Private _person As Person
    Private Sub Form1_Load(ByVal sender As ObjectByVal e As EventArgs) Handles Me.Load
        Me._person = New Person
        Dim b As New Binding("Text"Me._person, "Name")
        b.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged
        Me.TextBox1.DataBindings.Add(b)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As EventArgs) Handles Button1.Click
        MessageBox.Show(Me._person.Name)
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles TextBox1.TextChanged
        MessageBox.Show(Me._person.Name)
    End Sub

End Class

では、さっそく実行してみましょう♪TextBox1 に'abcde' と入力(直接入力で)して 出力結果をみてください。a、b、c・・・と入力した内容が、_person の Name プロパティに反映され(MessageBoxに表示され)ますか?


ふぁんたすてぃっく♪


# もしかしたらMessageBoxに表示される内容は、タイミング的に1つズレるかもしれません。これは Form1 のTextChanged ハンドラ と Binding クラスのハンドラの実行順序によるものだと思っていますが、 間違っていましたら、ご意見ご指摘お願いします。m(_ _)m


ちなみに、

MSDN:Binding.ControlUpdateMode プロパティ(http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.binding.controlupdatemode(VS.80).aspx)

ってのもあります。このプロパティは逆にデータ ソースの変更が、バインドされたコントロール プロパティにいつ反映されるかを設定できます。

このプロパティの型は

MSDN:ControlUpdateMode 列挙体(http://msdn2.microsoft.com/ja-jp/library/ms158470(VS.80).aspx)

です。規定値は OnPropertyChanged ですので、

データ ソース値が変更されるか、データ ソースの位置が変更されると、バインド コントロールが更新されます。

ですね。このように変更の通知とその反映のタイミングも制御できるなんて


とぉ~~~~~~~~~~~っても便利ですね♪


というお話でした。次回はその4でどっかで書きますって書いてた部分を書こうかなと思っています。(まだなにも考えてません・・・。)

投稿日時 : 2007年6月1日 14:11

Feedback

# データバインディングのおべんきょ。その11。 2007/06/04 10:51 とりこびと ぶろぐ。

データバインディングのおべんきょ。その11。

# re: Internet Explorer 11 で、右クリックしたときに表示されるメニューで、Bingではなく、Google をデフォルトの検索エンジンとして設定するには? 2017/12/08 18:13 meadc

http://www.ups-tracking.us ups shipping
http://www.hermesoutlet.co/ hermes outlet bag
http://www.prada-outlet-online.com/ prada outlet online store
http://www.louis--vuitton.co louis vuitton on sale
http://www.jimmy-choo.com.au
me adc12.8

# re: データバインディングのおべんきょ。その10。 2018/07/18 11:11 zzyytt

http://www.nike-huarache.com
http://www.hermes-birkin.us.com
http://www.nikedunks.us.org
http://www.michaelkors-outletfactory.us.org
http://www.mkoutletonlinestore.com
http://www.oakleysunglassesonline.us.org

# Asking questions are genuinely fastidious thing if you are not understanding anything fully, except this piece of writing offers fastidious understanding even. 2019/05/29 13:11 Asking questions are genuinely fastidious thing if

Asking questions are genuinely fastidious thing if you are not understanding anything fully, except this piece of writing offers fastidious understanding even.

# I love what you guys are usually up too. This kind of clever work and exposure! Keep up the fantastic works guys I've included you guys to my blogroll. 2019/05/31 21:59 I love what you guys are usually up too. This kind

I love what you guys are usually up too. This kind of clever work and exposure!
Keep up the fantastic works guys I've included you guys to my blogroll.

# great issues altogether, you just gained a new reader. What could you recommend about your put up that you made a few days ago? Any certain? 2019/06/03 4:31 great issues altogether, you just gained a new rea

great issues altogether, you just gained a new reader. What
could you recommend about your put up that
you made a few days ago? Any certain?

# Hi there to every body, it's my first go to see of this website; this weblog includes amazing and in fact good material for readers. 2019/06/05 14:23 Hi there to every body, it's my first go to see of

Hi there to every body, it's my first go to see
of this website; this weblog includes amazing
and in fact good material for readers.

# Hi, i think that i saw you visited my web site so i came to “return the favor”.I'm attempting to find things to improve my site!I suppose its ok to use a few of your ideas!! 2019/06/07 15:25 Hi, i think that i saw you visited my web site so

Hi, i think that i saw you visited my web site so i came to “return the favor”.I'm
attempting to find things to improve my site!I suppose its ok
to use a few of your ideas!!

# At this time I am ready to do my breakfast, once having my breakfast coming again to read more news. 2019/07/31 16:35 At this time I am ready to do my breakfast, once h

At this time I am ready to do my breakfast, once having my breakfast coming again to read more news.

# At this time I am ready to do my breakfast, once having my breakfast coming again to read more news. 2019/07/31 16:36 At this time I am ready to do my breakfast, once h

At this time I am ready to do my breakfast, once having my breakfast coming again to read more news.

# At this time I am ready to do my breakfast, once having my breakfast coming again to read more news. 2019/07/31 16:37 At this time I am ready to do my breakfast, once h

At this time I am ready to do my breakfast, once having my breakfast coming again to read more news.

# At this time I am ready to do my breakfast, once having my breakfast coming again to read more news. 2019/07/31 16:38 At this time I am ready to do my breakfast, once h

At this time I am ready to do my breakfast, once having my breakfast coming again to read more news.

# I am actually thankful to the holder of this web site who has shared this impressive article at at this time. 2019/09/04 5:02 I am actually thankful to the holder of this web s

I am actually thankful to the holder of this web site who has shared this impressive article at
at this time.

# I am actually thankful to the holder of this web site who has shared this impressive article at at this time. 2019/09/04 5:03 I am actually thankful to the holder of this web s

I am actually thankful to the holder of this web site who has shared this impressive article at
at this time.

# I am actually thankful to the holder of this web site who has shared this impressive article at at this time. 2019/09/04 5:04 I am actually thankful to the holder of this web s

I am actually thankful to the holder of this web site who has shared this impressive article at
at this time.

# I am actually thankful to the holder of this web site who has shared this impressive article at at this time. 2019/09/04 5:05 I am actually thankful to the holder of this web s

I am actually thankful to the holder of this web site who has shared this impressive article at
at this time.

# Hey there would you mind stating which blog platform you're using? I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design 2019/10/28 21:45 Hey there would you mind stating which blog platfo

Hey there would you mind stating which blog platform you're using?
I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask is because your design seems different
then most blogs and I'm looking for something unique.
P.S Apologies for being off-topic but I had to
ask!

# Hey there would you mind stating which blog platform you're using? I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design 2019/10/28 21:46 Hey there would you mind stating which blog platfo

Hey there would you mind stating which blog platform you're using?
I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask is because your design seems different
then most blogs and I'm looking for something unique.
P.S Apologies for being off-topic but I had to
ask!

# Hey there would you mind stating which blog platform you're using? I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design 2019/10/28 21:47 Hey there would you mind stating which blog platfo

Hey there would you mind stating which blog platform you're using?
I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask is because your design seems different
then most blogs and I'm looking for something unique.
P.S Apologies for being off-topic but I had to
ask!

# Hey there would you mind stating which blog platform you're using? I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design 2019/10/28 21:48 Hey there would you mind stating which blog platfo

Hey there would you mind stating which blog platform you're using?
I'm looking to start my own blog in the near future but I'm having a difficult time selecting between BlogEngine/Wordpress/B2evolution and
Drupal. The reason I ask is because your design seems different
then most blogs and I'm looking for something unique.
P.S Apologies for being off-topic but I had to
ask!

# I'm not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for great information I was looking for this information for my mission. 2019/11/20 15:55 I'm not sure where you are getting your info, but

I'm not sure where you are getting your info, but great topic.
I needs to spend some time learning more or understanding more.
Thanks for great information I was looking for this information for my mission.

# What a information of un-ambiguity and preserveness of valuable experience on the topic of unpredicted feelings. 2020/06/22 8:05 What a information of un-ambiguity and preservenes

What a information of un-ambiguity and preserveness of valuable experience on the
topic of unpredicted feelings.

タイトル  
名前  
Url
コメント