惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
罗磊的独立博客
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
MongoDB | Blog
MongoDB | Blog
The GitHub Blog
The GitHub Blog
G
Google Developers Blog
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
Jina AI
Jina AI
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Last Week in AI
Last Week in AI
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
C
Check Point Blog
GbyAI
GbyAI

博客园 - 什么都不知道

DataSet的Xml序列化问题 VB.NET的一个小问题 Access is denied的问题 - 什么都不知道 存储过程output参数问题 SQL Server的效率? datagrid刷新问题 使用Visio DrawingControl的应用开发(补) WinForm下TextBox的数据绑定和更新 使用Radio按钮选择DataGrid行 如何在运行时加载不处于应用程序目录下的assembly 使用VSA给程序加上脚本支持 删除所有Windows组件 在ASP.NET中嵌入wml标记 c#中动态装载dll 处理大型xml文件 RedirectToMobilePage的问题 使用Visio 2003 Drawing Control开发应用(3)(4) 使用Visio 2003 Drawing Control开发应用(2) 使用Visio 2003 Drawing Control开发应用(1)
突起效果的Label
什么都不知道 · 2004-10-12 · via 博客园 - 什么都不知道

现成的Winform下的Label控件的三种BorderStyle没有突起效果的,None, FixedSingle, Fixed3D。
要做个突起效果的,就继承一个Label来做。里面加上:

        protected override CreateParams CreateParams
        
{
            
get
            
{
                CreateParams cp 
= base.CreateParams;
                cp.ExStyle 
&= (~NativeMethods.WS_EXCLIENTEDGE);
                cp.Style 
&= (~NativeMethods.WS_BORDER);

                
switch(borderStyle)
                
{
                    
case BorderStyle.Fixed3D:
                        cp.ExStyle 
|= NativeMethods.WS_EXCLIENTEDGE;
                        
break;
                    
case BorderStyle.FixedSingle:
                        cp.Style 
|= NativeMethods.WS_BORDER;
                        
break;
                }

                
return cp;
            }

        }


        
public override BorderStyle BorderStyle
        
{
            
get
            
{
                
return borderStyle;
            }

            
set
            
{
                
if(borderStyle != value)
                
{
                    
if(!Enum.IsDefined(typeof(BorderStyle), value))
                    
{
                        
throw new InvalidEnumArgumentException("value", (int)value, typeof(BorderStyle));
                    }

                    borderStyle 
= value;
                    UpdateStyles();
                }

            }

        }

看结果,上面那个就是突起的Label
(代码就是MSDN里面那个创建有边框的UserControl的代码,呵呵,只是给不知道的人们看看,我上午就还不知道着呢)