zoukankan      html  css  js  c++  java
  • C# 中的一些常用方法

    //TextBox控件中只能输入数字和使用删除键
    private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (char.IsDigit(e.KeyChar) || e.KeyChar==8)
                    e.Handled = false;
                else
                    e.Handled = true;
            }
    //关闭窗口时弹出对话框,确定是否真的退出
    private void Form_Closing(object sender, FormClosingEventArgs e)
            {
                if (MessageBox.Show("你确定要退出本系统吗?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question,
    MessageBoxDefaultButton.Button1) == DialogResult.OK)
                    e.Cancel = false;
                else
                    e.Cancel = true;

            }
    //窗口控制中的常用方法
    1.窗口默认显示在屏幕中心位置
    在Form的Property窗口中,将“StartPosition”属性设置为“CerterScreen”即可。
     
    2.始终位于屏幕最前端
    在Form的Property窗口中,将“TopMost”属性设置为“True”即可。
    3.禁止窗口最大化
    在Form的Property窗口中,将“MaximizeBox”属性设置为“False”即可。
    4.禁止调整窗口大小
    在Form的Property窗口中,将“FormBorderStyle”属性设置为“FixedDialog”
    即可。
    同时,如果将“FormBorderStyle”属性设置为“FixedToolWindow”,则将得到一个只有关闭按钮的窗口。

    5.设置窗口是否MDI容器
    IsMdiContainer=true/false;
    当设置为true后,可以在主容器中添加子容器
    Form Form = new Form();
    Form.MdiParent = this;
    nForm.Show();

  • 相关阅读:
    汉语-词语:什么
    汉语-词语:甚么
    汉语-汉字:心
    汉语-词汇:头脑
    汉语-词语:冰冷
    汉语-词汇:冷静
    两个int类型的数据相加,有可能会出现超出int的表示范围。
    两个int类型的数据相加,有可能会出现超出int的表示范围。
    成员变量与局部变量的区别_
    函数额基本概述
  • 原文地址:https://www.cnblogs.com/elzero/p/817939.html
Copyright © 2011-2022 走看看