とりこらぼ。

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

目次

Blog 利用状況

ニュース

プロフィール

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

  • Wankuma MVP
    for '平々凡々'

Web Site

  • Memo(Of T)

もうひとつの Blog

広告っぽい

書庫

日記カテゴリ

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

すべてはここ↓から始まりました。

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

そうです。「TextBox の Text プロパティ にPerson クラス の Name プロパティをバインドしたろやないかいっ!」でしたね。もう遠い昔のようですね(だってもうその9だし)。

でも、これ、

なんで TextBox に入力したら Person クラス の Name プロパティが変更されたん?

不思議です。とっても不思議です。なのでちょっと調べてきました。すると、どうやら

「'プロパティ名' + Changed」 イベントの提供(コントロール側で。)

INotifyPropertyChanged インターフェイス の実装(コントロール側で。)

どちらかを行えばコントロールからデータへの変更も通知されるようです。TextBox のText プロパティは TextChanged イベントが対応しています。なので、Text プロパティにバインドされているデータのプロパティへの変更通知が行われるわけですね。

今回はその1で使用した Person クラスと Form1 をもう一度使用しますね。なお、今回コードの変更があるのは Form1 なのでそちらだけ改めてコードを載せておきます。

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
        Me.TextBox1.DataBindings.Add(New Binding("Text"Me._person, "Name"))
    End Sub

    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As EventArgs) Handles Button1.Click
        MessageBox.Show(Me._person.Name)
    End Sub

End Class

TextBox1 に 'とりこびと' と入力して Button1 をクリックしたら、MessageBox に 'とりこびと' と表示されたんでしたよね。

これにちょっとした検証するために Form1 に以下のコードを追加します。

    Private Sub TextBox1_TextChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles TextBox1.TextChanged

        MessageBox.Show(Me._person.Name)
    End Sub

Form1 でTextBox1 の TextChanged イベントをハンドルして Text プロパティが変更されたときに _person.Name がどうなっているかを出力するコードです。

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

・・・。

・・・ ・・・。

・・・ ・・・ ・・・。


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



Text プロパティが変更されたのに Name プロパティに反映されません。・・・困りましたね。



・・・と、困ったところで次回に♪

投稿日時 : 2007年6月1日 9:48

Feedback

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

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

# ZEyRstwESozKRRv 2011/12/13 18:37 http://www.d4women.net/clomid.php

Comrade kill yourself.

# prednisone online paypal https://prednisonesnw.com/#
buying prednisone from canada 2021/11/13 9:35 Prednisone

prednisone online paypal https://prednisonesnw.com/#
buying prednisone from canada

# does sildenafil 20 mg work https://viasild24.online/
2021/12/07 19:21 Nyusjdh

does sildenafil 20 mg work https://viasild24.online/

# finasteride hair https://finasteridemen.com/
2022/05/11 23:49 Finasteride

finasteride hair https://finasteridemen.com/

# prednisone buy https://deltasone.icu/
prednisone without prescription.net 2022/08/22 17:36 Prednisone

prednisone buy https://deltasone.icu/
prednisone without prescription.net

# metformin without prescription canada https://glucophage.top/
metformin tablets in india 2022/08/23 15:35 Niujsdkj

metformin without prescription canada https://glucophage.top/
metformin tablets in india

# top rated ed pills https://ed-pills.xyz/
top rated ed pills 2022/09/16 2:35 EdPills

top rated ed pills https://ed-pills.xyz/
top rated ed pills

# otc ed pills https://ed-pills.xyz/
ed pills otc 2022/09/17 15:01 EdPills

otc ed pills https://ed-pills.xyz/
ed pills otc

#  https://clomidforsale.site/ 2022/11/13 21:20 ForSale

https://clomidforsale.site/

# Read here. Cautions.
https://edonlinefast.com
Cautions. Generic Name. 2023/02/18 16:57 EdOnline

Read here. Cautions.
https://edonlinefast.com
Cautions. Generic Name.

# how to buy doxycycline online - https://doxycyclinesale.pro/# 2023/04/21 23:22 Doxycycline

how to buy doxycycline online - https://doxycyclinesale.pro/#

# buy cytotec - https://cytotecsale.pro/# 2023/04/29 6:30 Cytotec

buy cytotec - https://cytotecsale.pro/#

# over the counter pain meds https://overthecounter.pro/# 2023/05/09 0:35 OtcJikoliuj

over the counter pain meds https://overthecounter.pro/#

# aarp recommended canadian pharmacies https://pillswithoutprescription.pro/# 2023/05/15 5:18 PillsPresc

aarp recommended canadian pharmacies https://pillswithoutprescription.pro/#

# paxlovid pill https://paxlovid.pro/# - buy paxlovid online 2023/07/02 23:13 Paxlovid

paxlovid pill https://paxlovid.pro/# - buy paxlovid online

# buy cytotec over the counter https://cytotec.ink/# - buy cytotec pills online cheap 2023/07/26 20:30 PillsFree

buy cytotec over the counter https://cytotec.ink/# - buy cytotec pills online cheap

# erection pills online https://edpills.ink/# - best ed pills 2023/07/27 2:26 EdPills

erection pills online https://edpills.ink/# - best ed pills

# price of doxycycline https://doxycycline.forum/ doxycycline 2023/11/25 14:39 Doxycycline

price of doxycycline https://doxycycline.forum/ doxycycline

# best over the counter ed pills https://edpills.tech/# cures for ed 2023/12/23 9:32 EdPills

best over the counter ed pills https://edpills.tech/# cures for ed

# prednisone 40 mg price https://prednisonepharm.store/ buying prednisone mexico 2024/01/20 18:04 Prednisone

prednisone 40 mg price https://prednisonepharm.store/ buying prednisone mexico

# Abella Danger https://abelladanger.online/ abella danger video
2024/03/06 11:18 Adella

Abella Danger https://abelladanger.online/ abella danger video

タイトル  
名前  
Url
コメント