Протестировал

This commit is contained in:
bekodeg 2024-09-15 12:35:29 +04:00
parent 787de84492
commit 75ea67124a
15 changed files with 871 additions and 21 deletions

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cop.Borovkov.Var3", "Cop.Borovkov.Var3\Cop.Borovkov.Var3.csproj", "{A8604186-0CDE-4504-805B-46104141269A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cop.Borovkov.Var3", "Cop.Borovkov.Var3\Cop.Borovkov.Var3.csproj", "{A8604186-0CDE-4504-805B-46104141269A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestCustomComponents", "TestCustomComponents\TestCustomComponents.csproj", "{E2C46D08-ACCE-4547-922B-E92AD76D99C8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{A8604186-0CDE-4504-805B-46104141269A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8604186-0CDE-4504-805B-46104141269A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8604186-0CDE-4504-805B-46104141269A}.Release|Any CPU.Build.0 = Release|Any CPU
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2C46D08-ACCE-4547-922B-E92AD76D99C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,63 @@
namespace Cop.Borovkov.Var3.Components
{
partial class CustomDataTable
{
/// <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()
{
outDataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)outDataGridView).BeginInit();
SuspendLayout();
//
// outDataGridView
//
outDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
outDataGridView.ColumnHeadersVisible = false;
outDataGridView.Dock = DockStyle.Fill;
outDataGridView.Location = new Point(0, 0);
outDataGridView.Name = "outDataGridView";
outDataGridView.RowHeadersVisible = false;
outDataGridView.RowHeadersWidth = 51;
outDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
outDataGridView.Size = new Size(849, 396);
outDataGridView.TabIndex = 0;
//
// CustomDataTable
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(outDataGridView);
Name = "CustomDataTable";
Size = new Size(849, 396);
((System.ComponentModel.ISupportInitialize)outDataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView outDataGridView;
}
}

View File

@ -0,0 +1,104 @@
using Cop.Borovkov.Var3.Models;
namespace Cop.Borovkov.Var3.Components
{
public partial class CustomDataTable : UserControl
{
private readonly List<string> _columnsFildsNames = new();
public CustomDataTable()
{
InitializeComponent();
}
public void ConfigureColumns(params CustomDataTableColumnParameter[] columnParameters)
{
outDataGridView.Columns.Clear();
_columnsFildsNames.Clear();
for (int i = 0; i < columnParameters.Length; i++)
{
outDataGridView.Columns
.Add(columnParameters[i].HeaderName, columnParameters[i].HeaderName);
var column = outDataGridView.Columns[i];
column.Visible = columnParameters[i].Visible;
_columnsFildsNames.Add(column.Name);
if (columnParameters[i].Width != 0)
{
column.Width = columnParameters[i].Width;
}
else
{
column.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
}
}
}
/// <summary>
/// Отчистить таблицу
/// </summary>
public void Clear()
=> outDataGridView.Rows.Clear();
/// <summary>
/// Индекс выбранной строки
/// </summary>
public int SelectedRow
{
get => outDataGridView.CurrentRow.Index;
set
{
outDataGridView.CurrentRow.Selected = false;
outDataGridView.Rows[value].Selected = true;
}
}
public TType? GetRow<TType>(int rowIndex)
{
Type type = typeof(TType);
var element = type.GetConstructor([])?.Invoke([]);
if (element is null)
{
return default;
}
var row = outDataGridView.Rows[rowIndex].Cells;
for (int i = 0; i < outDataGridView.ColumnCount; i++)
{
if (string.IsNullOrEmpty(_columnsFildsNames[i]))
{
continue;
}
var field = type.GetProperty(_columnsFildsNames[i]);
field?.SetValue(element, row[i].Value);
}
return (TType)element;
}
public void Fill<TType>(IList<TType> insertValues)
{
Clear();
Type type = typeof(TType);
for (int i = 0; i < insertValues.Count(); ++i)
{
var row = insertValues[i];
outDataGridView.Rows.Add();
for (int j = 0; j < _columnsFildsNames.Count; ++j)
{
outDataGridView.Rows[i].Cells[j].Value
= type.GetProperty(_columnsFildsNames[j])?.GetValue(row)!;
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<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="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -31,22 +31,26 @@
InerlistBox = new ListBox();
SuspendLayout();
//
// inerlistBox
// InerlistBox
//
InerlistBox.Dock = DockStyle.Fill;
InerlistBox.FormattingEnabled = true;
InerlistBox.ItemHeight = 15;
InerlistBox.Location = new Point(0, 0);
InerlistBox.Name = "inerlistBox";
InerlistBox.Size = new Size(150, 150);
InerlistBox.Margin = new Padding(3, 2, 3, 2);
InerlistBox.Name = "InerlistBox";
InerlistBox.Size = new Size(131, 112);
InerlistBox.TabIndex = 0;
InerlistBox.ValueMemberChanged += InerlistBox_ValueMemberChanged;
InerlistBox.SelectedIndexChanged += InerlistBox_SelectedIndexChanged;
//
// CustomListBox
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(InerlistBox);
Margin = new Padding(3, 2, 3, 2);
Name = "CustomListBox";
Size = new Size(131, 112);
ResumeLayout(false);
}

View File

@ -2,7 +2,7 @@
{
public partial class CustomListBox : UserControl
{
private event EventHandler? _valueChanged;
private event EventHandler? _selectedChanged;
private event Action<Exception>? _errorOccured;
/// <summary>
@ -17,8 +17,8 @@
/// </summary>
public event EventHandler ValueChanged
{
add => _valueChanged += value;
remove => _valueChanged -= value;
add => _selectedChanged += value;
remove => _selectedChanged -= value;
}
/// <summary>
@ -43,13 +43,19 @@
/// <summary>
/// Очистить список
/// </summary>
public void Clear() => InerlistBox.Items.Clear();
public void Clear()
{
InerlistBox.ClearSelected();
InerlistBox.DataSource = null;
InerlistBox.Items.Clear();
InerlistBox.Refresh();
}
private void InerlistBox_ValueMemberChanged(object sender, EventArgs e)
private void InerlistBox_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
_valueChanged?.Invoke(sender, e);
_selectedChanged?.Invoke(sender, e);
}
catch (Exception ex)
{

View File

@ -35,7 +35,8 @@
// isNullcheckBox
//
isNullcheckBox.AutoSize = true;
isNullcheckBox.Location = new Point(3, 9);
isNullcheckBox.Location = new Point(3, 7);
isNullcheckBox.Margin = new Padding(3, 2, 3, 2);
isNullcheckBox.Name = "isNullcheckBox";
isNullcheckBox.Size = new Size(18, 17);
isNullcheckBox.TabIndex = 0;
@ -45,20 +46,22 @@
// inputField
//
inputField.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
inputField.Location = new Point(27, 3);
inputField.Location = new Point(24, 2);
inputField.Margin = new Padding(3, 2, 3, 2);
inputField.Name = "inputField";
inputField.Size = new Size(197, 27);
inputField.Size = new Size(173, 23);
inputField.TabIndex = 1;
inputField.DataContextChanged += InputField_DataContextChanged;
inputField.TextChanged += inputField_TextChanged;
//
// CustomNumericInputField
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(inputField);
Controls.Add(isNullcheckBox);
Margin = new Padding(3, 2, 3, 2);
Name = "CustomNumericInputField";
Size = new Size(227, 34);
Size = new Size(199, 26);
ResumeLayout(false);
PerformLayout();
}

View File

@ -88,7 +88,7 @@ namespace Cop.Borovkov.Var3.Components
}
}
private void InputField_DataContextChanged(object sender, EventArgs e)
private void inputField_TextChanged(object sender, EventArgs e)
{
try
{

View File

@ -0,0 +1,13 @@
namespace Cop.Borovkov.Var3.Models
{
public record CustomDataTableColumnParameter
{
public string HeaderName { get; init; } = string.Empty;
public int Width { get; init; } = 0;
public bool Visible { get; init; } = true;
public string PropertyName { get; init; } = string.Empty;
}
}

View File

@ -0,0 +1,246 @@
namespace TestCustomComponents
{
partial class Form1
{
/// <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 Windows Form 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()
{
customDataTable1 = new Cop.Borovkov.Var3.Components.CustomDataTable();
customListBox1 = new Cop.Borovkov.Var3.Components.CustomListBox();
customNumericInputField1 = new Cop.Borovkov.Var3.Components.CustomNumericInputField();
button1 = new Button();
button2 = new Button();
button3 = new Button();
richTextBox1 = new RichTextBox();
button4 = new Button();
button5 = new Button();
button6 = new Button();
button7 = new Button();
button8 = new Button();
button9 = new Button();
button10 = new Button();
button11 = new Button();
button12 = new Button();
SuspendLayout();
//
// customDataTable1
//
customDataTable1.Location = new Point(297, 23);
customDataTable1.Name = "customDataTable1";
customDataTable1.Size = new Size(491, 212);
customDataTable1.TabIndex = 0;
//
// customListBox1
//
customListBox1.Location = new Point(12, 11);
customListBox1.Margin = new Padding(3, 2, 3, 2);
customListBox1.Name = "customListBox1";
customListBox1.Selected = "";
customListBox1.Size = new Size(164, 140);
customListBox1.TabIndex = 1;
//
// customNumericInputField1
//
customNumericInputField1.Location = new Point(12, 155);
customNumericInputField1.Margin = new Padding(3, 2, 3, 2);
customNumericInputField1.Name = "customNumericInputField1";
customNumericInputField1.Size = new Size(249, 32);
customNumericInputField1.TabIndex = 2;
//
// button1
//
button1.Location = new Point(26, 309);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 3;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(126, 309);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 4;
button2.Text = "button2";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// button3
//
button3.Location = new Point(226, 309);
button3.Name = "button3";
button3.Size = new Size(94, 29);
button3.TabIndex = 5;
button3.Text = "button3";
button3.UseVisualStyleBackColor = true;
button3.Click += button3_Click;
//
// richTextBox1
//
richTextBox1.Location = new Point(567, 241);
richTextBox1.Name = "richTextBox1";
richTextBox1.Size = new Size(125, 165);
richTextBox1.TabIndex = 6;
richTextBox1.Text = "";
//
// button4
//
button4.Location = new Point(698, 241);
button4.Name = "button4";
button4.Size = new Size(94, 29);
button4.TabIndex = 7;
button4.Text = "button4";
button4.UseVisualStyleBackColor = true;
button4.Click += button4_Click;
//
// button5
//
button5.Location = new Point(26, 344);
button5.Name = "button5";
button5.Size = new Size(94, 29);
button5.TabIndex = 8;
button5.Text = "button5";
button5.UseVisualStyleBackColor = true;
button5.Click += button5_Click;
//
// button6
//
button6.Location = new Point(126, 344);
button6.Name = "button6";
button6.Size = new Size(94, 29);
button6.TabIndex = 9;
button6.Text = "button6";
button6.UseVisualStyleBackColor = true;
button6.Click += button6_Click;
//
// button7
//
button7.Location = new Point(226, 344);
button7.Name = "button7";
button7.Size = new Size(94, 29);
button7.TabIndex = 10;
button7.Text = "button7";
button7.UseVisualStyleBackColor = true;
button7.Click += button7_Click;
//
// button8
//
button8.Location = new Point(26, 379);
button8.Name = "button8";
button8.Size = new Size(94, 29);
button8.TabIndex = 11;
button8.Text = "button8";
button8.UseVisualStyleBackColor = true;
button8.Click += button8_Click;
//
// button9
//
button9.Location = new Point(126, 377);
button9.Name = "button9";
button9.Size = new Size(94, 29);
button9.TabIndex = 12;
button9.Text = "button9";
button9.UseVisualStyleBackColor = true;
button9.Click += button9_Click;
//
// button10
//
button10.Location = new Point(226, 377);
button10.Name = "button10";
button10.Size = new Size(94, 29);
button10.TabIndex = 13;
button10.Text = "button10";
button10.UseVisualStyleBackColor = true;
button10.Click += button10_Click;
//
// button11
//
button11.Location = new Point(26, 414);
button11.Name = "button11";
button11.Size = new Size(94, 29);
button11.TabIndex = 14;
button11.Text = "button11";
button11.UseVisualStyleBackColor = true;
button11.Click += button11_Click;
//
// button12
//
button12.Location = new Point(126, 414);
button12.Name = "button12";
button12.Size = new Size(94, 29);
button12.TabIndex = 15;
button12.Text = "button12";
button12.UseVisualStyleBackColor = true;
button12.Click += button12_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(button12);
Controls.Add(button11);
Controls.Add(button10);
Controls.Add(button9);
Controls.Add(button8);
Controls.Add(button7);
Controls.Add(button6);
Controls.Add(button5);
Controls.Add(button4);
Controls.Add(richTextBox1);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(customNumericInputField1);
Controls.Add(customListBox1);
Controls.Add(customDataTable1);
Name = "Form1";
Text = "Form1";
ResumeLayout(false);
}
#endregion
private Cop.Borovkov.Var3.Components.CustomDataTable customDataTable1;
private Cop.Borovkov.Var3.Components.CustomListBox customListBox1;
private Cop.Borovkov.Var3.Components.CustomNumericInputField customNumericInputField1;
private Button button1;
private Button button2;
private Button button3;
private RichTextBox richTextBox1;
private Button button4;
private Button button5;
private Button button6;
private Button button7;
private Button button8;
private Button button9;
private Button button10;
private Button button11;
private Button button12;
}
}

View File

@ -0,0 +1,122 @@
using TestCustomComponents.Models;
namespace TestCustomComponents
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Log(string message)
{
richTextBox1.Text = $"{richTextBox1.Text}\n{message}";
}
private void button1_Click(object sender, EventArgs e)
{
customListBox1.AnErrorOccurred += ex => Log(ex.Message);
customListBox1.ValueChanged += (obj, sender) => Log($"Selected1 is {customListBox1.Selected}");
customNumericInputField1.AnErrorOccurred += ex => Log(ex.Message);
customNumericInputField1.NumericInputChanged += (obj, sender) => Log("Test 4 ok");
customListBox1.FillValues(["hello", "world", "123", "321"]);
customListBox1.Selected = "123";
}
private void button2_Click(object sender, EventArgs e)
{
customListBox1.Clear();
customListBox1.Selected = "234";
}
private void button3_Click(object sender, EventArgs e)
{
Log($"Selected2 is {customNumericInputField1.Value?.ToString() ?? "null"}");
}
private void button4_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void button5_Click(object sender, EventArgs e)
{
customNumericInputField1.Value = 3333;
}
private void button6_Click(object sender, EventArgs e)
{
customNumericInputField1.Value = null;
}
private void button7_Click(object sender, EventArgs e)
{
customDataTable1.ConfigureColumns(
new()
{
HeaderName = "Id",
PropertyName = nameof(TestModel.Id),
Visible = false,
},
new()
{
HeaderName = "Name",
PropertyName = nameof(TestModel.Name),
Width = 100,
},
new()
{
HeaderName = "Age",
PropertyName = nameof(TestModel.Age),
}
);
}
private void button8_Click(object sender, EventArgs e)
{
customDataTable1.Fill<TestModel>([
new(){
Id = 1,
Name = "Vasya",
Age = 5,
},
new()
{
Id = 2,
Name = "Vilthare",
Age = 3,
},
new()
{
Id = 3,
Name = "MOMO",
Age = 10,
},
]);
}
private void button9_Click(object sender, EventArgs e)
{
customDataTable1.Clear();
}
private void button10_Click(object sender, EventArgs e)
{
Log($"selected3 {customDataTable1.SelectedRow}");
}
private void button11_Click(object sender, EventArgs e)
{
customDataTable1.SelectedRow = customNumericInputField1.Value!.Value;
}
private void button12_Click(object sender, EventArgs e)
{
var elem = customDataTable1.GetRow<TestModel>(customDataTable1.SelectedRow)!;
Log($"Selected: id={elem.Id} name={elem.Name} age={elem.Age}");
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<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="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,11 @@
namespace TestCustomComponents.Models
{
public class TestModel
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
}

View File

@ -0,0 +1,17 @@
namespace TestCustomComponents
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}
}

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Cop.Borovkov.Var3\Cop.Borovkov.Var3.csproj" />
</ItemGroup>
</Project>