• c# 小技巧


    設置控件的標準顏色類:
        System.Drawing.SystemColors類

    0到9之間數字的ASCII值:
        0到9之間數字的ASCII值是48到57,所以就保證字符在這個範圍內。ASCII值8表示退格鍵。

    控件的操作無效
        KeyPressEventArgs的Handled屬性設置為True,告訴控件不就對字符進行任何操作。

    如得到ToolStrip中的子控件

                //循環得到ToolStrip中的子控件
                
    //循環整個窗體(FrontHelper.mfrmMain為一個Form)
                foreach (Control btn in FrontHelper.mfrmMain.Controls)
                {
                    
    //判斷btn是不是ToolStrip控件
                    if (btn is ToolStrip)
                    {
                        ToolStrip ts 
    = new ToolStrip();
                        
    //將控件btn轉換為ToolStrip控件
                        ts = (ToolStrip)btn;
                        
    foreach (ToolStripItem ctn in ts.Items)
                        {
                            
    //判斷ctn是不是ToolStripButton控件
                            if (ctn is ToolStripButton)
                            {                            
                                
    if (ctn.Tag != null)
                                {
                                    
    if (ctn.Tag.ToString().ToLower() == "new")
                                    {
                                        ctn.Enabled 
    = false;
                                    }
                                }
                            }
                        }
                    }
                }


    如何在C#中鎖定窗口大小
    //隱藏最大化圖標
    Form1.MaximizeBox=false;  
    //設置窗體的樣式為固:定且單一的線條框線。
    Form1.FormBorderStyle=FixedSingle;  

    激活當前體
                //激活當前體(將活動窗設為當前)
                this.Activate();



  • 相关阅读:
    Blend3中创建的Silverlight程序在设计模式下无法显示图片的解决办法
    创建Silverlight Bussiness Application时报错的解决
    .NET 2.0 字符串比较
    ASP.NET 客户端缓存
    AjaxPro部署成功
    遭遇反序列化异常:"在分析完成之前就遇到流结尾"
    正则表达式
    哈哈,终于申请获得批准了!
    ClientScript.RegisterClientScriptInclude注册脚本
    今天经过一场深有体会的谈话终于决定了我2012的方向
  • 原文地址:https://www.cnblogs.com/scottckt/p/921955.html
Copyright © 2020-2023  润新知