*UICheckBoxGroup :增加SetItemCheckState功能
This commit is contained in:
parent
4d91059b2d
commit
2a551ae48f
Binary file not shown.
Binary file not shown.
15
SunnyUI.Demo/Controls/FCheckBox.Designer.cs
generated
15
SunnyUI.Demo/Controls/FCheckBox.Designer.cs
generated
@ -41,6 +41,7 @@ namespace Sunny.UI.Demo
|
|||||||
this.uiCheckBox3 = new Sunny.UI.UICheckBox();
|
this.uiCheckBox3 = new Sunny.UI.UICheckBox();
|
||||||
this.uiLine1 = new Sunny.UI.UILine();
|
this.uiLine1 = new Sunny.UI.UILine();
|
||||||
this.uiCheckBox1 = new Sunny.UI.UICheckBox();
|
this.uiCheckBox1 = new Sunny.UI.UICheckBox();
|
||||||
|
this.uiButton6 = new Sunny.UI.UIButton();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// uiButton5
|
// uiButton5
|
||||||
@ -195,11 +196,24 @@ namespace Sunny.UI.Demo
|
|||||||
this.uiCheckBox1.Text = "uiCheckBox1";
|
this.uiCheckBox1.Text = "uiCheckBox1";
|
||||||
this.uiCheckBox1.CheckedChanged += new System.EventHandler(this.uiCheckBox1_CheckedChanged);
|
this.uiCheckBox1.CheckedChanged += new System.EventHandler(this.uiCheckBox1_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// uiButton6
|
||||||
|
//
|
||||||
|
this.uiButton6.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.uiButton6.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||||
|
this.uiButton6.Location = new System.Drawing.Point(560, 345);
|
||||||
|
this.uiButton6.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.uiButton6.Name = "uiButton6";
|
||||||
|
this.uiButton6.Size = new System.Drawing.Size(100, 35);
|
||||||
|
this.uiButton6.TabIndex = 58;
|
||||||
|
this.uiButton6.Text = "单选";
|
||||||
|
this.uiButton6.Click += new System.EventHandler(this.uiButton6_Click);
|
||||||
|
//
|
||||||
// FCheckBox
|
// FCheckBox
|
||||||
//
|
//
|
||||||
this.AllowShowTitle = true;
|
this.AllowShowTitle = true;
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 521);
|
this.ClientSize = new System.Drawing.Size(800, 521);
|
||||||
|
this.Controls.Add(this.uiButton6);
|
||||||
this.Controls.Add(this.uiButton5);
|
this.Controls.Add(this.uiButton5);
|
||||||
this.Controls.Add(this.uiButton4);
|
this.Controls.Add(this.uiButton4);
|
||||||
this.Controls.Add(this.uiButton3);
|
this.Controls.Add(this.uiButton3);
|
||||||
@ -233,5 +247,6 @@ namespace Sunny.UI.Demo
|
|||||||
private UICheckBox uiCheckBox3;
|
private UICheckBox uiCheckBox3;
|
||||||
private UILine uiLine1;
|
private UILine uiLine1;
|
||||||
private UICheckBox uiCheckBox1;
|
private UICheckBox uiCheckBox1;
|
||||||
|
private UIButton uiButton6;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,5 +54,10 @@ namespace Sunny.UI.Demo
|
|||||||
{
|
{
|
||||||
Console.WriteLine(uiCheckBox1.Checked);
|
Console.WriteLine(uiCheckBox1.Checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void uiButton6_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
uiCheckBoxGroup1[4] = !uiCheckBoxGroup1[4];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,12 @@ namespace Sunny.UI
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool this[int index]
|
||||||
|
{
|
||||||
|
get => GetItemCheckState(index);
|
||||||
|
set => SetItemCheckState(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 析构事件
|
/// 析构事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -185,6 +191,22 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetItemCheckState(int index, bool isChecked)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < boxes.Count)
|
||||||
|
{
|
||||||
|
boxes[index].Checked = isChecked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool GetItemCheckState(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index < items.Count)
|
||||||
|
return boxes[index].Checked;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//[Browsable(false)]
|
//[Browsable(false)]
|
||||||
//public List<string> SelectedItems
|
//public List<string> SelectedItems
|
||||||
//{
|
//{
|
||||||
@ -207,15 +229,15 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
List<object> items = new List<object>();
|
List<object> objects = new List<object>();
|
||||||
|
|
||||||
for (int i = 0; i < boxes.Count; i++)
|
for (int i = 0; i < boxes.Count; i++)
|
||||||
{
|
{
|
||||||
if (boxes[i].Checked)
|
if (boxes[i].Checked)
|
||||||
items.Add(Items[i]);
|
objects.Add(Items[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return items;
|
return objects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,6 @@
|
|||||||
<EmbeddedResource Include="Font\fa-solid-900.ttf" />
|
<EmbeddedResource Include="Font\fa-solid-900.ttf" />
|
||||||
<EmbeddedResource Include="Font\FontAwesome.ttf" />
|
<EmbeddedResource Include="Font\FontAwesome.ttf" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="SunnyUI.Common" Version="3.0.8" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
@ -71,6 +67,10 @@
|
|||||||
<Reference Include="System.Design" />
|
<Reference Include="System.Design" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="SunnyUI.Common" Version="3.0.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user