C# winform 中控件禁用,但是不变灰
来源:互联网 发布:内存卡恢复数据 编辑:程序博客网 时间:2024/05/29 07:30
[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;
}
文章转载自:http://bbs.csdn.net/topics/350241687
- C# winform 中控件禁用,但是不变灰
- 让你的EDIT控件禁用了不变灰
- C#禁用关闭按钮(变灰)
- C#的Winform中使用用户控件
- C# WinForm中控件与背景透明
- C#多线程异步访问winform中控件
- c# WinForm中查找控件,动态赋值
- C#多线程异步访问winform中控件
- C# 在winform中查找控件
- C# WinForm程序中使用Unity3D控件
- C# WinForm中添加用户控件
- C# 使用多线程访问winform中控件
- C# WinForm中使用WPF的控件
- C#多线程异步访问winform中控件
- C# WinForm程序中使用Unity3D控件
- C#多线程中访问winform控件
- C#多线程异步访问winform中控件
- C#中Winform绑定dategridview控件
- Android 更换 RatingBar背景图片
- UVA 10537 The Toll! Revisited(最短路变形)
- 【创想QQ图标点亮辅助工具●V2.0官方版】
- Jquery选择器总结
- HDU 4300Clairewd’s message(题目不好懂 KMP)
- C# winform 中控件禁用,但是不变灰
- Eclipse中10个最有用的快捷键组合
- 第二个类:SimpleMailSender.java
- 使用Minify来优化网站性能
- 最近读设计模式有感
- [leetcode] Multiply Strings
- WTL框架
- MAC常用命令
- Oracle 11gR2(11.2.0.3) Patchset (p10404530)中7个不同文件的作用说明