Test first component.

This commit is contained in:
ElEgEv 2023-09-12 12:27:56 +04:00
parent 1be19b8943
commit 51152f5d9b
5 changed files with 68 additions and 34 deletions

View File

@ -1,6 +1,6 @@
namespace VisualComponentsForm
{
partial class Form1
partial class FormMain
{
/// <summary>
/// Required designer variable.
@ -28,10 +28,10 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
components = new System.ComponentModel.Container();
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Text = "Form1";
}
#endregion

View File

@ -1,8 +1,8 @@
namespace VisualComponentsForm
{
public partial class Form1 : Form
public partial class FormMain : Form
{
public Form1()
public FormMain()
{
InitializeComponent();
}

View File

@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>

View File

@ -11,7 +11,7 @@ namespace VisualComponentsForm
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(new FormMain());
}
}
}

View File

@ -8,6 +8,40 @@ 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;
}
}
}