WinControlExtensionLib/WinControlExtension.cs

(完整代码) 1KB

using System.Windows.Forms;

namespace WinControlExtensionLib
{
    public static class WinControlExtension
    {
        public delegate void ControlTextMethod(Control control, Form CFrom, string text);
        public delegate void ControlEnableMethod(Control control, Form CFrom, bool enable);

        public static void SetControlText(this Control control, Form CFrom, string text)
        {
            if (CFrom.InvokeRequired)
            {
                ControlTextMethod controlTextMethod = SetControlText;
                CFrom.Invoke(controlTextMethod, new object[] { control, CFrom, text });
            }
            else
            {
                control.Text = text;
            }
            Application.DoEvents();
        }

        public static void SetControlEnable(this Control control, Form CFrom, bool enable)
        {
            if (CFrom.InvokeRequired)
            {
                ControlEnableMethod controlEnableMethod = SetControlEnable;
                CFrom.Invoke(controlEnableMethod, new object[] { control, CFrom, enable });
            }
            else
            {
                control.Enabled = enable;
            }
            Application.DoEvents();
        }

    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。