控件的enable=false的时候字体的颜色为灰色,有什么办法可以使它变为其他的颜色?

解决方案 »

  1.   

    如果事先为enable=false,那么改为true,接下来改颜色,改完有将其设计为false
      

  2.   


            [System.Runtime.InteropServices.DllImport("user32.dll ")]
            public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc);
            [System.Runtime.InteropServices.DllImport("user32.dll ")]
            public static extern int GetWindowLong(IntPtr hWnd, int nIndex);        public const int GWL_STYLE = -16;
            public const int WS_DISABLED = 0x8000000;        public static void SetControlEnabled(Control c, bool enabled)
            {
                if (enabled)
                { SetWindowLong(c.Handle, GWL_STYLE, (~WS_DISABLED) & GetWindowLong(c.Handle, GWL_STYLE)); }
                else
                { SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLED + GetWindowLong(c.Handle, GWL_STYLE)); }
            }        private void button2_Click(object sender, System.EventArgs e)
            {
                SetControlEnabled(this.button1, false);
                this.button1.ForeColor = Color.White;
            }
      

  3.   

    就试过combox enable属性。设置为false的时候那个颜色改不了,郁闷。