* UICheckBox: 修复AutoSize在文字改变时未自动显示的问题,#IAKYX4

* UIRadioButton: 修复AutoSize在文字改变时未自动显示的问题,#IAKYX4
This commit is contained in:
Sunny 2024-08-26 22:49:49 +08:00
parent 7cf009af36
commit fcb55cbae4
2 changed files with 18 additions and 4 deletions

View File

@ -24,6 +24,7 @@
* 2023-05-12: V3.3.6 DrawString函数
* 2023-11-07: V3.5.2
* 2023-12-04: V3.6.1
* 2024-08-26: V3.6.9 AutoSize在文字改变时未自动显示的问题#IAKYX4
******************************************************************************/
using System;
@ -67,8 +68,8 @@ namespace Sunny.UI
if (AutoSize && Dock == DockStyle.None)
{
Size sf = TextRenderer.MeasureText(Text, Font);
int w = sf.Width + CheckBoxSize + 3;
int h = Math.Max(CheckBoxSize, sf.Height) + 2;
int w = sf.Width + CheckBoxSize + 7;
int h = Math.Max(CheckBoxSize, sf.Height) + 5;
if (Width != w) Width = w;
if (Height != h) Height = h;
}
@ -253,5 +254,11 @@ namespace Sunny.UI
get => fillColor;
set => SetFillColor(value);
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Invalidate();
}
}
}

View File

@ -25,6 +25,7 @@
* 2023-05-12: V3.3.6 DrawString函数
* 2023-11-07: V3.5.2
* 2023-12-04: V3.6.1
* 2024-08-26: V3.6.9 AutoSize在文字改变时未自动显示的问题#IAKYX4
******************************************************************************/
using System;
@ -68,8 +69,8 @@ namespace Sunny.UI
if (AutoSize && Dock == DockStyle.None)
{
Size sf = TextRenderer.MeasureText(Text, Font);
int w = sf.Width + RadioButtonSize + 3;
int h = Math.Max(RadioButtonSize, sf.Height) + 2;
int w = sf.Width + RadioButtonSize + 7;
int h = Math.Max(RadioButtonSize, sf.Height) + 5;
if (Width != w) Width = w;
if (Height != h) Height = h;
}
@ -268,5 +269,11 @@ namespace Sunny.UI
get => fillColor;
set => SetFillColor(value);
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Invalidate();
}
}
}