using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace praktika6 { public partial class Form1 : Form { public Form1() { InitializeComponent(); TextBox textBox1 = new TextBox(); textBox1.Location = new Point(12, 12); textBox1.Size = new Size(250, 27); Controls.Add(textBox1); Label label1 = new Label(); label1.Location = new Point(12, 60); label1.AutoSize = true; Controls.Add(label1); label1.DataBindings.Add(new Binding("Text", textBox1, "Text")); textBox1.Location = new Point(12, 12); textBox1.Size = new Size(250, 27); Controls.Add(textBox1); label1.Location = new Point(12, 60); label1.AutoSize = true; Controls.Add(label1); Binding binding = new Binding("Text", textBox1, "Text"); binding.Format += (sender, e) => e.Value = $"Content: {e.Value}"; InitializeComponent(); DateTimePicker dateTimePicker1 = new DateTimePicker(); dateTimePicker1.Location = new Point(12, 12); dateTimePicker1.Size = new Size(250, 27); Controls.Add(dateTimePicker1); label1.Location = new Point(12, 60); label1.AutoSize = true; Controls.Add(label1); dateTimePicker1.Location = new Point(12, 12); dateTimePicker1.Size = new Size(250, 27); Controls.Add(dateTimePicker1); label1.Location = new Point(12, 60); label1.AutoSize = true; Controls.Add(label1); // создаем объект привязки // делаем доступным форматирование binding.FormattingEnabled = true; // строка форматирования binding.FormatString = "dd.MM.yyyy"; } } }