Compare commits
13 Commits
v1.0.2
...
fix_lab2_a
| Author | SHA1 | Date | |
|---|---|---|---|
| 71a2524338 | |||
| 0221ad1e7a | |||
| 315c6f7249 | |||
| 6c60e093cc | |||
| 062f92babb | |||
| 340c7d9b1f | |||
| c4d07c4ee2 | |||
| 77b1ea495f | |||
| 48fc1a8443 | |||
| c853d7790c | |||
| f128da5093 | |||
| 811e94e0ce | |||
| d5384363ab |
@@ -56,7 +56,12 @@ namespace Components
|
|||||||
var property = data.GetType().GetProperty(headersConfig[rowIndex].propertyName);
|
var property = data.GetType().GetProperty(headersConfig[rowIndex].propertyName);
|
||||||
if (property != null)
|
if (property != null)
|
||||||
{
|
{
|
||||||
worksheet.Cells[rowIndex + 2, colIndex + 3].Value = property.GetValue(data);
|
if(property.PropertyType == typeof(DateOnly))
|
||||||
|
{
|
||||||
|
worksheet.Cells[rowIndex + 2, colIndex + 3].Value = property.GetValue(data).ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
worksheet.Cells[rowIndex + 2, colIndex + 3].Value = property.GetValue(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<Authors>ns.potapov</Authors>
|
<Authors>ns.potapov</Authors>
|
||||||
<VersionPrefix>1.0.2</VersionPrefix>
|
<VersionPrefix>1.1.0</VersionPrefix>
|
||||||
<Version>$(VersionPrefix)</Version>
|
<Version>$(VersionPrefix)</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace Components.Exceptions
|
||||||
|
{
|
||||||
|
internal class MaxCheckedItemsCountExceedException : Exception
|
||||||
|
{
|
||||||
|
public MaxCheckedItemsCountExceedException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaxCheckedItemsCountExceedException(string? message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,22 +36,20 @@
|
|||||||
checkedListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
checkedListBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
checkedListBox.CheckOnClick = true;
|
checkedListBox.CheckOnClick = true;
|
||||||
checkedListBox.FormattingEnabled = true;
|
checkedListBox.FormattingEnabled = true;
|
||||||
checkedListBox.Location = new Point(9, 8);
|
checkedListBox.Location = new Point(8, 6);
|
||||||
checkedListBox.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
checkedListBox.Name = "checkedListBox";
|
checkedListBox.Name = "checkedListBox";
|
||||||
checkedListBox.Size = new Size(509, 400);
|
checkedListBox.Size = new Size(446, 292);
|
||||||
checkedListBox.TabIndex = 0;
|
checkedListBox.TabIndex = 0;
|
||||||
checkedListBox.ItemCheck += checkedListBox_ItemCheck;
|
checkedListBox.ItemCheck += checkedListBox_ItemCheck;
|
||||||
//
|
//
|
||||||
// UserControlCheckedList
|
// UserControlCheckedList
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
BackColor = Color.Firebrick;
|
BackColor = Color.Firebrick;
|
||||||
Controls.Add(checkedListBox);
|
Controls.Add(checkedListBox);
|
||||||
Margin = new Padding(3, 4, 3, 4);
|
|
||||||
Name = "UserControlCheckedList";
|
Name = "UserControlCheckedList";
|
||||||
Size = new Size(527, 415);
|
Size = new Size(461, 311);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,25 @@
|
|||||||
namespace Components
|
using Components.Exceptions;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Components
|
||||||
{
|
{
|
||||||
|
public enum Types : int
|
||||||
|
{
|
||||||
|
Exception = 0,
|
||||||
|
DeleteFirst = 1,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public partial class UserControlCheckedList : UserControl
|
public partial class UserControlCheckedList : UserControl
|
||||||
{
|
{
|
||||||
|
public int MaxCheckedItemsCount { get; set; } = 1;
|
||||||
|
private Types typeOfMaxChecked = Types.DeleteFirst;
|
||||||
private EventHandler _onCheckedItemChangedEvent;
|
private EventHandler _onCheckedItemChangedEvent;
|
||||||
|
public void ChangeTypeOfMaxChecked(Types type)
|
||||||
|
{
|
||||||
|
typeOfMaxChecked = type;
|
||||||
|
}
|
||||||
public event EventHandler CheckedItemChanged
|
public event EventHandler CheckedItemChanged
|
||||||
{
|
{
|
||||||
add
|
add
|
||||||
@@ -28,6 +45,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public List<string> CheckedItemss
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
foreach (var item in checkedListBox.CheckedItems)
|
||||||
|
{
|
||||||
|
list.Add(item.ToString());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
foreach (var item in value)
|
||||||
|
{
|
||||||
|
if (checkedListBox.Items.Contains(item))
|
||||||
|
{
|
||||||
|
checkedListBox.SetItemCheckState(checkedListBox.Items.IndexOf(item), CheckState.Checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public UserControlCheckedList()
|
public UserControlCheckedList()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -46,14 +85,24 @@
|
|||||||
}
|
}
|
||||||
private void checkedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
|
private void checkedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < checkedListBox.Items.Count; i++)
|
this.BeginInvoke((MethodInvoker)(
|
||||||
|
() =>
|
||||||
{
|
{
|
||||||
if (i != e.Index)
|
if (checkedListBox.CheckedItems.Count > MaxCheckedItemsCount)
|
||||||
{
|
{
|
||||||
checkedListBox.SetItemChecked(i, false);
|
if (typeOfMaxChecked == Types.Exception)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Превышено максимальное число выбранных элементов");
|
||||||
|
checkedListBox.SetItemChecked(e.Index, false);
|
||||||
|
}
|
||||||
|
else if (typeOfMaxChecked == Types.DeleteFirst)
|
||||||
|
{
|
||||||
|
checkedListBox.SetItemCheckState(checkedListBox.Items.IndexOf(CheckedItem), CheckState.Unchecked);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
_onCheckedItemChangedEvent?.Invoke(sender, e);
|
||||||
_onCheckedItemChangedEvent?.Invoke(sender, e);
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace WinFormsApp
|
|||||||
list.Add("<22><><EFBFBD><EFBFBD><EFBFBD>");
|
list.Add("<22><><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
list.Add("C#");
|
list.Add("C#");
|
||||||
userControlCheckedList.SetCheckedListBoxValues(list);
|
userControlCheckedList.SetCheckedListBoxValues(list);
|
||||||
|
userControlCheckedList.MaxCheckedItemsCount = 3;
|
||||||
userControlCheckedList.CheckedItem = list[3];
|
userControlCheckedList.ChangeTypeOfMaxChecked(Components.Types.DeleteFirst);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonClearList_Click(object sender, EventArgs e)
|
private void buttonClearList_Click(object sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user