Правки

This commit is contained in:
ElEgEv 2023-09-13 09:58:42 +04:00
parent 51152f5d9b
commit bb487bf6e1
9 changed files with 111 additions and 101 deletions

View File

@ -5,6 +5,8 @@ VisualStudioVersion = 17.6.33815.320
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsForm", "VisualComponentsForm\VisualComponentsForm.csproj", "{29E20B1C-11E3-4B0D-A614-097ACBB21263}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsForm", "VisualComponentsForm\VisualComponentsForm.csproj", "{29E20B1C-11E3-4B0D-A614-097ACBB21263}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisualComponentsLib", "..\VisualComponentsLib\VisualComponentsLib.csproj", "{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Debug|Any CPU.Build.0 = Debug|Any CPU {29E20B1C-11E3-4B0D-A614-097ACBB21263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.ActiveCfg = Release|Any CPU {29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.Build.0 = Release|Any CPU {29E20B1C-11E3-4B0D-A614-097ACBB21263}.Release|Any CPU.Build.0 = Release|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5B8AE30-4836-44F8-AC47-75D2B05D73EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -8,4 +8,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\VisualComponentsLib\VisualComponentsLib.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,47 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VisualComponentsLib.CustomListBox
{
public class MyListBox : ListBox
{
//получение выбранного значения
string _chooiceElem { get; set; } = string.Empty;
//делегат на смену значения
public delegate void GetNewVal(string data, EventArgs e);
//событие
public event GetNewVal ChangeSelectedVal;
//base constructor; привязываем событие к делегату
public MyListBox() : base()
{
ChangeSelectedVal += _changeSelectedVal;
}
public void _addNewElem(string data)
{
Items.Add(data);
}
public void _clearListBox()
{
Items.Clear();
}
public void _clickToList(string data, EventArgs e)
{
ChangeSelectedVal(data, e);
}
//перезапись поля при событии смены значения
public void _changeSelectedVal(string data, EventArgs e)
{
_chooiceElem = data;
}
}
}

View File

@ -0,0 +1,60 @@
namespace VisualComponentsLib.CustomListBox
{
partial class UserListBox
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором компонентов
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
listBox = new ListBox();
SuspendLayout();
//
// listBox
//
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
listBox.FormattingEnabled = true;
listBox.ItemHeight = 15;
listBox.Location = new Point(3, 3);
listBox.Name = "listBox";
listBox.Size = new Size(234, 229);
listBox.TabIndex = 0;
//
// UserListBox
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(listBox);
Location = new Point(3, 5);
MinimumSize = new Size(84, 53);
Name = "UserListBox";
Size = new Size(240, 240);
ResumeLayout(false);
}
#endregion
private ListBox listBox;
}
}

View File

@ -0,0 +1,36 @@
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;
using System.ComponentModel;
namespace VisualComponentsLib.CustomListBox
{
[DefaultEvent(nameof(TextChanged))]
public partial class UserListBox : UserControl
{
[Browsable(true)]
public string selectedString
{
get => listBox.SelectedItem.ToString();
set => listBox.SelectedItem = value;
}
public UserListBox()
{
InitializeComponent();
}
[Browsable(true)]
public new event EventHandler? TextChanged
{
add => listBox.Items.Add(value);
remove => listBox.Items.Clear();
}
}
}

View File

@ -1,44 +0,0 @@
namespace VisualComponentsLib
{
partial class UserControl1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
//
// UserControl1
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Name = "UserControl1";
Size = new Size(800, 450);
ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace VisualComponentsLib
{
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
}

View File

@ -7,4 +7,9 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Folder Include="CustomTextBox\" />
<Folder Include="CustomDataGridView\" />
</ItemGroup>
</Project> </Project>