修复inputnumber鼠标长按加减导致的跨线程问题

This commit is contained in:
czz_y 2024-09-05 09:06:54 +08:00
parent 5534b3ed1f
commit eb30901846
5 changed files with 41 additions and 6 deletions

View File

@ -156,14 +156,21 @@ namespace AntdUIDemo.Views
// 添加清理逻辑
public void CloseFloatButtonForm()
{
if (InvokeRequired)
{
Invoke(new Action(CloseFloatButtonForm));
return;
}
if (floatButtonForm != null)
{
floatButtonForm?.Close();
floatButtonForm?.Dispose();
floatButtonForm.Close();
floatButtonForm.Dispose();
floatButtonForm = null;
}
}
#region EventHandler
private void select_intvalue_SelectedIndexChanged(object sender, IntEventArgs e)
{

View File

@ -91,12 +91,18 @@ namespace AntdUIDemo.Views
#region
private void select_intvalue_SelectedIndexChanged(object sender, IntEventArgs e)
{
flowPanel.Align = (TAlignFlow)select_align.SelectedValue;
if (flowPanel.InvokeRequired)
{
flowPanel.Invoke(new Action(() => { flowPanel.Align = (TAlignFlow)select_align.SelectedValue; }));
}
}
private void input_gap_ValueChanged(object sender, DecimalEventArgs e)
{
flowPanel.Gap = (int)input_gap.Value;
if (flowPanel.InvokeRequired)
{
flowPanel.Invoke(new Action(() => { flowPanel.Gap = (int)input_gap.Value; }));
}
}
// 添加按钮
private void buttonADD_Click(object sender, EventArgs e)

View File

@ -37,6 +37,11 @@ namespace AntdUIDemo.Views
private void LoadGridPanel(string spantext, decimal gap)
{
if (gridPanel.InvokeRequired)
{
gridPanel.Invoke(new Action(() => LoadGridPanel(spantext, gap)));
return;
}
gridPanel.Controls.Clear();
gridPanel.Span = spantext;
gridPanel.Gap = (int)gap;

View File

@ -78,6 +78,11 @@ namespace AntdUIDemo.Views
private void LoadPanel()
{
if (panel.InvokeRequired)
{
panel.Invoke(new Action(() => LoadPanel()));
return;
}
panel.ArrowAlign = (TAlign)select_arrowalign.SelectedValue;
panel.ArrowSize = (int)input_arrowsize.Value;
panel.Radius = (int)input_radius.Value;

View File

@ -82,12 +82,24 @@ namespace AntdUIDemo.Views
private void input_itemsize_TextChanged(object sender, EventArgs e)
{
stackPanel.ItemSize = input_itemsize.Text;
if (stackPanel.InvokeRequired)
{
stackPanel.Invoke(new Action(() =>
{
stackPanel.ItemSize = input_itemsize.Text;
}));
}
}
private void input_gap_ValueChanged(object sender, DecimalEventArgs e)
{
stackPanel.Gap = (int)input_gap.Value;
if (stackPanel.InvokeRequired)
{
stackPanel.Invoke(new Action(() =>
{
stackPanel.Gap = (int)input_gap.Value;
}));
}
}
private void ButtonDEL_Click(object sender, EventArgs e)