0% found this document useful (0 votes)
11 views6 pages

FVCS9311 S12 Notes

This document discusses BindingContext and CurrencyManager in Windows Forms applications. It explains that every form has a BindingContext object that manages control connections within the form. The BindingContext manages CurrencyManager objects, whose role is to synchronize controls bound to the same data source, like a DataSet. It also describes how to use the DataBindings.Add method to bind controls to data.

Uploaded by

alemrajabi.safat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

FVCS9311 S12 Notes

This document discusses BindingContext and CurrencyManager in Windows Forms applications. It explains that every form has a BindingContext object that manages control connections within the form. The BindingContext manages CurrencyManager objects, whose role is to synchronize controls bound to the same data source, like a DataSet. It also describes how to use the DataBindings.Add method to bind controls to data.

Uploaded by

alemrajabi.safat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

‫س‬ ‫ر‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬

‫‪ CurrencyManager‬ﻭ ‪BindingContext‬‬

‫د‬ ‫ﻫﺮ ﻓﺮﻡ ﺩﺍﺭﺍﻱ ﺷﻴﺌﻲ ﺍﺯ ﻧﻮﻉ ‪BindingContext‬ﺍﺳﺖ ﻛﻪ‬


‫ﺍﺗﺼﺎﻻﺕ ﻛﻨﺘﺮﻝﻫﺎﻱ ﺩﺭﻭﻥ ﻓﺮﻡ ﺭﺍ ﻣﺪﻳﺮﻳﺖ ﻣﻲﻛﻨﺪ‪ .‬ﺑﻨﺎﺑﺮﺍﻳﻦ‬
‫ﺑﻪ ﻋﻠﺖ ﺍﻳﻨﻜﻪ ﻓﺮﻡ ﺑﺮﻧﺎﻣﻪ ﺷﻤﺎ ﺑﻪ ﺻﻮﺭﺕ ﺩﺭﻭﻧﻲ ﺩﺍﺭﺍﻱ ﭼﻨﻴﻦ‬

‫‪r‬‬ ‫‪g‬‬
‫ﺷﻴﺌﻲ ﺍﺳﺖ‪ ،‬ﻧﻴﺎﺯﻱ ﻧﻴﺴﺖ ﻛﻪ ﺁﻥ ﺭﺍ ﺍﻳﺠﺎﺩ ﻛﻨﻴﺪ‪.‬‬

‫‪s‬‬ ‫‪.‬‬‫‪o‬‬
‫ﺷﻲ ‪BindingContext‬ﺩﺭ ﺣﻘﻴﻘﺖ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﺍﺯ‬

‫‪a‬‬ ‫‪r‬‬
‫ﺍﺷﻴﺎء ﺍﺯ ﻧـﻮﻉ ‪CurrencyManager‬ﺭﺍ ﻣـﺪﻳﺮﻳﺖ‬

‫‪a‬‬‫‪D‬‬
‫ﻣـﻲﻛﻨـﺪ‪ .‬ﻭﻇﻴﻔـﻪﻱ ‪ CurrencyManager‬ﻧﻴﺰ ﺍﻳﻦ‬

‫‪F‬‬ ‫‪a‬‬‫‪r‬‬
‫ﺍﺳﺖ ﻛﻪ ﺑﻴﻦ ﺗﻤﺎﻡ ﻛﻨﺘﺮﻝﻫﺎﻳﻲ ﻛﻪ ﺑﻪ ﻳﻚ ﻣﻨﺒﻊ ﺩﺍﺩﻩ)ﻣﺜﻼً‬
‫‪ (DataSet‬ﻣﺘﺼﻞ ﻫﺴﺘﻨﺪ ﻫﻤﺎﻫﻨﮕﻲ ﺑﺮﻗﺮﺍﺭ ﻛﻨﺪ‪.‬‬

‫;‪CurrencyManager cr‬‬
‫;]"‪cr = (CurrencyManager)this.BindingContext[ds, "t1‬‬
‫‪1‬‬
‫س‬ ‫ر‬ ‫د‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬ ‫‪DataBindings‬‬
‫ﺑﻪ ﻛﻤﻚ ﻣﺘﺪ ‪ Add‬ﺍﺯ ‪DataBindings‬‬
‫ﻛﻨﺘﺮﻝ ﻫﺎ ﻣﻲﺗﻮﺍﻥ ﺑﺮﺍﻱ ﺁﻧﻬﺎ ﻣﻨﺒﻊ ﺩﺍﺩﻩ‬

‫‪r‬‬ ‫‪g‬‬
‫ﺗﻌﻴﻴﻦ ﻛﺮﺩ‪ .‬ﺷﻜﻞ ﻛﻠﻲ ﺍﻳﻦ ﻣﺘﺪ ﺑﻪ ﺷﻜﻞ‬

‫‪s‬‬ ‫‪.‬‬‫‪o‬‬
‫ﺯﻳﺮ ﺍﺳﺖ‪.‬‬

‫‪F‬‬ ‫‪a‬‬‫‪r‬‬ ‫‪a‬‬‫‪D‬‬ ‫‪a‬‬ ‫‪r‬‬


‫ﻭﺭﻭﺩﻱ ﺍﻭﻝ‪ ،‬ﻧﺎﻡ ﺧﺼﻮﺻﻴﺘﻲ ﺍﺳﺖ ﻛﻪ ﻣﻲﺧﻮﺍﻫﻴﺪ ﺑﺮﺍﻱ ﺁﻥ ﻣﻨﺒﻊ ﺩﺍﺩﻩ ﺗﻌﺮﻳﻒ ﻛﻨﻴﺪ‪ .‬ﭘﺎﺭﺍﻣﺘﺮ ﺩﻭﻡ‪ ،‬ﻧﺎﻡ‬
‫‪ DataSet‬ﺟﺎﺭﻱ ﻣﻲﺑﺎﺷﺪ ﻭ ﭘﺎﺭﺍﻣﺘﺮ ﺳﻮﻡ‪ ،‬ﻧﺎﻡ ﺟﺰﺋﻲ ﺍﺯ‪ DataSet‬ﺍﺳﺖ ﻛﻪ ﻣﻲﺧﻮﺍﻫﻴﺪ ﺑﻪ ﻋﻨﻮﺍﻥ‬
‫ﻣﻨﺒﻊ ﺩﺍﺩﻩ ﺗﻌﺮﻳﻒ ﻛﻨﻴﺪ‪.‬‬
‫‪2‬‬
‫د‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬
‫ﺗﻤﺮﻳﻦ‪ :‬ﺑﺮﻧﺎﻣﻪ ﺣﺬﻑ ﺭﻛﻮﺭﺩ ﺭﺍ ﺑﻪ ﻧﺤﻮﻱ ﺗﻐﻴﻴﺮ ﺩﻫﻴﺪ ﻛﻪ‬

‫س‬ ‫ر‬
‫ﻫﻤﺎﻧﻨﺪ ﺷﻜﻞ ﺯﻳﺮ ﻗﺒﻞ ﺍﺯ ﺣﺬﻑ ﺭﻛﻮﺭﺩ‪ ،‬ﺑﻪ ﻛﻤﻚ ﻳﻚ‬
‫‪ messagebox‬ﺍﺯ ﻛﺎﺭﺑﺮ ﺗﺄﻳﻴﺪﻳﻪ ﺣﺬﻑ ﺭﻛﻮﺭﺩ ﻣﺬﻛﻮﺭ ﺭﺍ‬

‫‪g‬‬
‫ﺩﺭﻳﺎﻓﺖ ﻛﻨﺪ‪.‬‬

‫‪D‬‬ ‫‪a‬‬ ‫‪r‬‬ ‫‪s‬‬ ‫‪.‬‬‫‪o‬‬‫‪r‬‬


‫‪F‬‬ ‫‪a‬‬‫‪r‬‬ ‫‪a‬‬ ‫‪3‬‬
‫د‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬
‫ﺗﻤﺮﻳﻦ‪ :‬ﺑﺮﻧﺎﻣﻪ ﺩﻓﺘﺮﭼﻪ ﺗﻠﻔﻦ ﺭﺍ ﺑﻪ ﻧﺤﻮﻱ ﺗﻐﻴﻴﺮ ﺩﻫﻴﺪ ﻛﻪ ﺗﺼﻮﻳﺮ ﻣﺸﺘﺮﻙ ﺗﻠﻔﻦ ﺭﺍ‬

‫س‬ ‫ر‬
‫ﻣﻄﺎﺑﻖ ﺷﻜﻞ ﺯﻳﺮ ﺛﺒﺖ ﻛﻨﺪ‪ .‬ﺩﻗﺖ ﻛﻨﻴﺪ ﻛﻪ ﺍﻳﻦ ﺑﺨﺶ ﺑﺎﻳﺪ ﺩﺭ ﺗﻤﺎﻡ ﻗﺴﻤﺖﻫﺎﻱ‬
‫ﺑﺮﻧﺎﻣﻪ)ﻭﻳﺮﺍﻳﺶ‪ ،‬ﺣﺬﻑ‪ ،‬ﺑﻌﺪﻱ‪ ،‬ﻗﺒﻠﻲ ﻭ‪ (...‬ﺩﺭﺳﺖ ﻛﺎﺭ ﻛﻨﺪ‪.‬‬

‫‪a‬‬ ‫‪r‬‬ ‫‪s‬‬ ‫‪.‬‬‫‪o‬‬‫‪r‬‬ ‫‪g‬‬


‫‪F‬‬ ‫‪a‬‬‫‪r‬‬ ‫‪a‬‬‫‪D‬‬
‫‪4‬‬
‫د‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬
‫ﺗﻤﺮﻳﻦ‪ :‬ﺑﺮﻧﺎﻣﻪ ﺩﻓﺘﺮﭼﻪ ﺗﻠﻔﻦ ﺭﺍ ﺑﻪ ﻧﺤﻮﻱ ﺗﻐﻴﻴﺮﺩﻫﻴﺪ ﻛﻪ ﺑﺎ ﻛﻠﻴﻚ ﻛﺮﺩﻥ ﺑﺮﺭﻭﻱ‬

‫س‬ ‫ر‬ ‫ﺗﺼﻮﻳﺮ‪ ،‬ﻋﻜﺲ ﺷﺨﺺ ﺑﺎ ﺍﺑﻌﺎﺩ ﻭﺍﻗﻌﻲ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﺷﻮﺩ‪.‬‬

‫‪a‬‬ ‫‪r‬‬ ‫‪s‬‬ ‫‪.‬‬‫‪o‬‬‫‪r‬‬ ‫‪g‬‬


‫‪F‬‬ ‫‪a‬‬‫‪r‬‬ ‫‪a‬‬‫‪D‬‬
‫‪5‬‬
‫د‬ ‫ا‬ ‫ﺮ‬ ‫ﻓ‬
‫ﺗﻤﺮﻳﻦ‪ :‬ﺑﺮﻧﺎﻣﻪﺍﻱ ﺑﻨﻮﻳﺴﻴﺪ ﻛﻪ ﻳﻚ ﺩﻳﻜﺸﻨﺮﻱ ﺭﺍ ﺑﻄﻮﺭ ﻛﺎﻣﻞ ﭘﻴﺎﺩﻩﺳﺎﺯﻱ ﻛﻨﺪ‪ .‬ﺑﺎﻧﻚ‬

‫س‬ ‫ر‬
‫ﺍﻃﻼﻋﺎﺗﻲ ﺍﻳﻦ ﺩﻳﻜﺸﻨﺮﻱ ﺣﺎﻭﻱ ﻳﻚ ﺟﺪﻭﻝ ﺑﻨﺎﻡ ‪ Words‬ﺑﺎ ﺷﻜﻞ ﺯﻳﺮ ﺍﺳﺖ‪.‬‬

‫‪a‬‬ ‫‪r‬‬ ‫‪s‬‬ ‫‪.‬‬‫‪o‬‬‫‪r‬‬ ‫‪g‬‬


‫‪F‬‬ ‫‪a‬‬‫‪r‬‬ ‫‪a‬‬‫‪D‬‬ ‫ﻓﺮﻡ ﺍﺻﻠﯽ ﺩﻳﮑﺸﻨﺮی ﺑﻪ ﺷﮑﻞ ﻣﻘﺎﺑﻞ ﺍﺳﺖ‬
‫‪6‬‬

You might also like