do
This commit is contained in:
parent
7d7ce6cb91
commit
a9749528c7
28
Library15Gerimovich/DefaultList.Designer.cs
generated
28
Library15Gerimovich/DefaultList.Designer.cs
generated
@ -28,30 +28,34 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.listBox = new System.Windows.Forms.ListBox();
|
||||
this.MainListBox = new System.Windows.Forms.ListBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
// MainListBox
|
||||
//
|
||||
this.listBox.FormattingEnabled = true;
|
||||
this.listBox.ItemHeight = 15;
|
||||
this.listBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.listBox.Name = "listBox";
|
||||
this.listBox.Size = new System.Drawing.Size(144, 109);
|
||||
this.listBox.TabIndex = 0;
|
||||
this.MainListBox.FormattingEnabled = true;
|
||||
this.MainListBox.ItemHeight = 15;
|
||||
this.MainListBox.Items.AddRange(new object[] {
|
||||
"RITG",
|
||||
"SimbirSoft",
|
||||
"MediaSoft"});
|
||||
this.MainListBox.Location = new System.Drawing.Point(3, 3);
|
||||
this.MainListBox.Name = "MainListBox";
|
||||
this.MainListBox.Size = new System.Drawing.Size(144, 109);
|
||||
this.MainListBox.TabIndex = 0;
|
||||
//
|
||||
// DefoltList
|
||||
// DefaultList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.listBox);
|
||||
this.Name = "DefoltList";
|
||||
this.Controls.Add(this.MainListBox);
|
||||
this.Name = "DefaultList";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
private ListBox MainListBox;
|
||||
}
|
||||
}
|
||||
|
@ -12,47 +12,91 @@ namespace Library15Gerimovich
|
||||
{
|
||||
public partial class DefaultList : UserControl
|
||||
{
|
||||
public event EventHandler? SelectedValueChanged;
|
||||
private event EventHandler? _itemSelected;
|
||||
|
||||
public string SelectedValue
|
||||
public DefaultList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
// метод, передающий строку
|
||||
public void SetItems(string Items)
|
||||
{
|
||||
get
|
||||
string[] itemArray = Items.Split(','); // разбиваем по запятым
|
||||
|
||||
MainListBox.Items.Clear();
|
||||
|
||||
foreach (var item in itemArray)
|
||||
{
|
||||
return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
int index = checkedListBox1.Items.IndexOf(value);
|
||||
if (index >= 0)
|
||||
{
|
||||
checkedListBox1.SelectedIndex = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
checkedListBox1.ClearSelected();
|
||||
}
|
||||
MainListBox.Items.Add(item.Trim()); // Trim для удаления пробелов
|
||||
}
|
||||
}
|
||||
public void ClearList()
|
||||
{
|
||||
MainListBox.Items.Clear();
|
||||
}
|
||||
|
||||
public DefaultList()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
// установка, получение выбранного элемента
|
||||
public string SelectedItem
|
||||
{
|
||||
get { return (string?)MainListBox.SelectedItem ?? string.Empty; }
|
||||
set { MainListBox.SelectedItem = value; }
|
||||
}
|
||||
|
||||
public void AddItemToList(string item)
|
||||
{
|
||||
ListBox.Items.Add(item);
|
||||
}
|
||||
public event EventHandler? ItemSelected
|
||||
{
|
||||
add { _itemSelected += value; }
|
||||
remove { _itemSelected -= value; }
|
||||
}
|
||||
|
||||
private void SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
SelectedValueChanged?.Invoke(this, e);
|
||||
}
|
||||
// контролируем смену значений
|
||||
private void MainListBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_itemSelected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public void ClearComboBox()
|
||||
{
|
||||
checkedListBox1.Items.Clear();
|
||||
}
|
||||
//public event EventHandler? SelectedValueChanged;
|
||||
|
||||
//public string SelectedValue
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// int index = checkedListBox1.Items.IndexOf(value);
|
||||
// if (index >= 0)
|
||||
// {
|
||||
// checkedListBox1.SelectedIndex = index;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// checkedListBox1.ClearSelected();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
//public DefaultList()
|
||||
//{
|
||||
// InitializeComponent();
|
||||
//}
|
||||
|
||||
//public void AddItemToList(string item)
|
||||
//{
|
||||
// ListBox.Items.Add(item);
|
||||
//}
|
||||
|
||||
//private void SelectedIndexChanged(object sender, EventArgs e)
|
||||
//{
|
||||
// SelectedValueChanged?.Invoke(this, e);
|
||||
//}
|
||||
|
||||
//public void ClearComboBox()
|
||||
//{
|
||||
// checkedListBox1.Items.Clear();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
2
Library15Gerimovich/InputRealNumber.Designer.cs
generated
2
Library15Gerimovich/InputRealNumber.Designer.cs
generated
@ -41,6 +41,7 @@
|
||||
this.IsNullCheckBox.TabIndex = 0;
|
||||
this.IsNullCheckBox.Text = "Нулевое значение";
|
||||
this.IsNullCheckBox.UseVisualStyleBackColor = true;
|
||||
this.IsNullCheckBox.CheckedChanged += new System.EventHandler(this.IsNullCheckBox_CheckedChanged);
|
||||
//
|
||||
// MainTextBox
|
||||
//
|
||||
@ -48,6 +49,7 @@
|
||||
this.MainTextBox.Name = "MainTextBox";
|
||||
this.MainTextBox.Size = new System.Drawing.Size(127, 23);
|
||||
this.MainTextBox.TabIndex = 1;
|
||||
this.MainTextBox.TextChanged += new System.EventHandler(this.MainTextBox_TextChanged);
|
||||
//
|
||||
// InputRealNumber
|
||||
//
|
||||
|
@ -20,10 +20,7 @@ namespace Library15Gerimovich
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка и получение введенного значения
|
||||
/// </summary>
|
||||
public int? IntValue
|
||||
public double? DoubleValue
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -37,10 +34,10 @@ namespace Library15Gerimovich
|
||||
throw new EmptyValueException();
|
||||
}
|
||||
|
||||
int ParsedInt;
|
||||
if (Int32.TryParse(MainTextBox.Text, out ParsedInt))
|
||||
double ParsedDouble;
|
||||
if (double.TryParse(MainTextBox.Text, out ParsedDouble))
|
||||
{
|
||||
return ParsedInt;
|
||||
return ParsedDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -57,9 +54,6 @@ namespace Library15Gerimovich
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Событие, вызываемое при смене значения (либо при смене CheckBox)
|
||||
/// </summary>
|
||||
public event EventHandler? ValueChanged
|
||||
{
|
||||
add { _valueChanged += value; }
|
||||
|
@ -68,30 +68,30 @@ namespace Library15Gerimovich
|
||||
}
|
||||
}
|
||||
|
||||
public TType? GetRow<TType>(int rowIndex)
|
||||
{
|
||||
Type type = typeof(TType);
|
||||
var element = type.GetConstructor([])?.Invoke([]);
|
||||
//public TType? GetRow<TType>(int rowIndex)
|
||||
//{
|
||||
// Type type = typeof(TType);
|
||||
// var element = type.GetConstructor([])?.Invoke([]);
|
||||
|
||||
if (element is null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
// if (element is null)
|
||||
// {
|
||||
// return default;
|
||||
// }
|
||||
|
||||
var row = dataGridViewOut.Rows[rowIndex].Cells;
|
||||
// var row = dataGridViewOut.Rows[rowIndex].Cells;
|
||||
|
||||
for (int i = 0; i < dataGridViewOut.ColumnCount; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_columnsFildsNames[i]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var field = type.GetProperty(_columnsFildsNames[i]);
|
||||
field?.SetValue(element, row[i].Value);
|
||||
}
|
||||
// for (int i = 0; i < dataGridViewOut.ColumnCount; i++)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(_columnsFildsNames[i]))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// var field = type.GetProperty(_columnsFildsNames[i]);
|
||||
// field?.SetValue(element, row[i].Value);
|
||||
// }
|
||||
|
||||
return (TType)element;
|
||||
}
|
||||
// return (TType)element;
|
||||
//}
|
||||
|
||||
public void Fill<TType>(IList<TType> insertValues)
|
||||
{
|
||||
|
33
WinFormsAppTest/Form1.Designer.cs
generated
33
WinFormsAppTest/Form1.Designer.cs
generated
@ -29,20 +29,48 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.userControl11 = new Library15Gerimovich.UserControl1();
|
||||
this.defaultList1 = new Library15Gerimovich.DefaultList();
|
||||
this.inputRealNumber1 = new Library15Gerimovich.InputRealNumber();
|
||||
this.outputTableResults1 = new Library15Gerimovich.OutputTableResults();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// userControl11
|
||||
//
|
||||
this.userControl11.Location = new System.Drawing.Point(54, 19);
|
||||
this.userControl11.Avatar = null;
|
||||
this.userControl11.Location = new System.Drawing.Point(12, 242);
|
||||
this.userControl11.Name = "userControl11";
|
||||
this.userControl11.Size = new System.Drawing.Size(150, 144);
|
||||
this.userControl11.TabIndex = 0;
|
||||
//
|
||||
// defaultList1
|
||||
//
|
||||
this.defaultList1.Location = new System.Drawing.Point(12, 12);
|
||||
this.defaultList1.Name = "defaultList1";
|
||||
this.defaultList1.Size = new System.Drawing.Size(150, 150);
|
||||
this.defaultList1.TabIndex = 1;
|
||||
//
|
||||
// inputRealNumber1
|
||||
//
|
||||
this.inputRealNumber1.Location = new System.Drawing.Point(202, 34);
|
||||
this.inputRealNumber1.Name = "inputRealNumber1";
|
||||
this.inputRealNumber1.Size = new System.Drawing.Size(135, 101);
|
||||
this.inputRealNumber1.TabIndex = 2;
|
||||
//
|
||||
// outputTableResults1
|
||||
//
|
||||
this.outputTableResults1.Location = new System.Drawing.Point(422, 34);
|
||||
this.outputTableResults1.Name = "outputTableResults1";
|
||||
this.outputTableResults1.Size = new System.Drawing.Size(259, 245);
|
||||
this.outputTableResults1.TabIndex = 3;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.outputTableResults1);
|
||||
this.Controls.Add(this.inputRealNumber1);
|
||||
this.Controls.Add(this.defaultList1);
|
||||
this.Controls.Add(this.userControl11);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
@ -53,5 +81,8 @@
|
||||
#endregion
|
||||
|
||||
private Library15Gerimovich.UserControl1 userControl11;
|
||||
private Library15Gerimovich.DefaultList defaultList1;
|
||||
private Library15Gerimovich.InputRealNumber inputRealNumber1;
|
||||
private Library15Gerimovich.OutputTableResults outputTableResults1;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user