zoukankan      html  css  js  c++  java
  • 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();



  • 相关阅读:
    编程学习杂烩
    设计模式
    redis
    H5
    Java
    db工具
    python + pip
    mysql
    Spring Security
    Spring Cloud Gateway
  • 原文地址:https://www.cnblogs.com/scottckt/p/921955.html
Copyright © 2011-2022 走看看