From bf736e563dab21782ecdb92943b37ebf2b9c4220 Mon Sep 17 00:00:00 2001 From: ElEgEv <112943269+ElEgEv@users.noreply.github.com> Date: Wed, 13 Sep 2023 12:53:53 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserDataGridView.Designer.cs | 52 ++++++++++++++++++- VisualComponentsLib/UserDataGridView.cs | 13 +++++ VisualComponentsLib/UserDataGridView.resx | 52 +++++++++---------- VisualComponentsLib/UserTextBox.Designer.cs | 36 ++++++++++++- VisualComponentsLib/UserTextBox.cs | 41 +++++++++++++++ VisualComponentsLib/UserTextBox.resx | 52 +++++++++---------- 6 files changed, 190 insertions(+), 56 deletions(-) diff --git a/VisualComponentsLib/UserDataGridView.Designer.cs b/VisualComponentsLib/UserDataGridView.Designer.cs index 9760fa5..80471bb 100644 --- a/VisualComponentsLib/UserDataGridView.Designer.cs +++ b/VisualComponentsLib/UserDataGridView.Designer.cs @@ -28,10 +28,58 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonClear = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(3, 3); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(417, 459); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(446, 23); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(123, 23); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить значение"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonClear + // + buttonClear.Location = new Point(446, 76); + buttonClear.Name = "buttonClear"; + buttonClear.Size = new Size(123, 23); + buttonClear.TabIndex = 2; + buttonClear.Text = "Очистить всё"; + buttonClear.UseVisualStyleBackColor = true; + buttonClear.Click += ButtonClear_Click; + // + // UserDataGridView + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(buttonClear); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "UserDataGridView"; + Size = new Size(598, 465); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); } #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonClear; } } diff --git a/VisualComponentsLib/UserDataGridView.cs b/VisualComponentsLib/UserDataGridView.cs index cd901ea..f40b481 100644 --- a/VisualComponentsLib/UserDataGridView.cs +++ b/VisualComponentsLib/UserDataGridView.cs @@ -12,9 +12,22 @@ namespace VisualComponentsLib { public partial class UserDataGridView : UserControl { + + public UserDataGridView() { InitializeComponent(); } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + + } + + //полная очистка + private void ButtonClear_Click(object sender, EventArgs e) + { + dataGridView.Rows.Clear(); + } } } diff --git a/VisualComponentsLib/UserDataGridView.resx b/VisualComponentsLib/UserDataGridView.resx index 1af7de1..a395bff 100644 --- a/VisualComponentsLib/UserDataGridView.resx +++ b/VisualComponentsLib/UserDataGridView.resx @@ -1,24 +1,24 @@  - diff --git a/VisualComponentsLib/UserTextBox.Designer.cs b/VisualComponentsLib/UserTextBox.Designer.cs index ba88e43..aa4313e 100644 --- a/VisualComponentsLib/UserTextBox.Designer.cs +++ b/VisualComponentsLib/UserTextBox.Designer.cs @@ -28,10 +28,42 @@ /// private void InitializeComponent() { - components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + checkBox = new CheckBox(); + textBox = new TextBox(); + SuspendLayout(); + // + // checkBox + // + checkBox.AutoSize = true; + checkBox.Location = new Point(14, 52); + checkBox.Name = "checkBox"; + checkBox.Size = new Size(104, 19); + checkBox.TabIndex = 0; + checkBox.Text = "Включить null"; + checkBox.UseVisualStyleBackColor = true; + // + // textBox + // + textBox.Location = new Point(14, 12); + textBox.Name = "textBox"; + textBox.Size = new Size(182, 23); + textBox.TabIndex = 2; + // + // UserTextBox + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + Controls.Add(textBox); + Controls.Add(checkBox); + Name = "UserTextBox"; + Size = new Size(210, 80); + ResumeLayout(false); + PerformLayout(); } #endregion + + private CheckBox checkBox; + private TextBox textBox; } } diff --git a/VisualComponentsLib/UserTextBox.cs b/VisualComponentsLib/UserTextBox.cs index 6e75169..f1f2f08 100644 --- a/VisualComponentsLib/UserTextBox.cs +++ b/VisualComponentsLib/UserTextBox.cs @@ -12,9 +12,50 @@ namespace VisualComponentsLib { public partial class UserTextBox : UserControl { + public string inputString + { + get => textBox.Text; + set => textBox.Text = value; + } + + public new event EventHandler? TextChanged + { + add => textBox.Text = value.ToString(); + remove => textBox.Text = string.Empty; + } + public UserTextBox() { InitializeComponent(); } + + public void clickCheckBox() + { + if(checkBox.Checked) + { + textBox.ReadOnly = true; + + inputString = string.Empty; + + textBox.Text = string.Empty; + } + + if(!checkBox.Checked) + { + try + { + double support; + + if (Double.TryParse(textBox.Text, out support)) + { + inputString = textBox.Text; + } + } + catch (Exception ex) + { + MessageBox.Show("Введённое значение не является вещественным числом."); + } + } + } } } diff --git a/VisualComponentsLib/UserTextBox.resx b/VisualComponentsLib/UserTextBox.resx index 1af7de1..a395bff 100644 --- a/VisualComponentsLib/UserTextBox.resx +++ b/VisualComponentsLib/UserTextBox.resx @@ -1,24 +1,24 @@  -