Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- bindingSource1.DataSource = Class1.Instance;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Class1.Instance.MyProperty = "Jhoiheofcjwp";
- }
- }
- public class Class1 : INotifyPropertyChanged
- {
- private Class1() { }
- private static Class1 instance;
- public static Class1 Instance
- {
- get
- {
- if (instance == null) instance = new Class1();
- return instance;
- }
- }
- private string myProperty = "Hallo";
- public string MyProperty
- {
- get { return myProperty; }
- set { myProperty = value; OnPropertyChanged(); }
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement