ContextMenuStrip

  添加控件后可在其他空间属性中进行绑定


MenuStrip
       设置热键:在编辑的时候输入(&F)
       设置快捷键:选中菜单项--右键属性--ShortCutKeys--设置快捷键
       设置分隔线:在输入的时候输入减号(-)


StatusStrip
       状态栏,可以添加按钮,文本等


ToolStrip
       在ToolStripContainer控件内可被拖动修改位置


ToolStripContainer
       帮助ToolStrip布局控件


计算器

/// <summary>
        /// 根据点击的控件输入数字
        /// </summary>
        /// <param name="e"></param>
        private void shuru(string str)
        {
            "||qk){
                textBox1.Text = str;
                qk = false;
            }
            else
                textBox1.Text += str;
        }
        /// <summary>
        /// 输入数字
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void b0_Click(object sender, EventArgs e)
        {
            shuru((sender as Control).Text);
        }
        /// <summary>
        /// 小数点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dian_Click(object sender, EventArgs e)
        {
            if(!textBox1.Text.Contains("."))
                textBox1.Text+=".";
        }
        /// <summary>
        /// 退格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void back_Click(object sender, EventArgs e)
        {
            )
                textBox1.Text = ";
            else
                textBox1.Text = textBox1.Text.Substring(, textBox1.TextLength-);
        }
        /// <summary>
        /// 根据按下的按键键入计算符号
        /// </summary>
        /// <param name="e"></param>
        private void jis(string str)
        {
            if (qk) {
                if (shang != str) {
                    textBox2.Text = textBox2.Text.Substring(, textBox2.TextLength - ) + str;
                    shang = str;
                }
            }
            else
            {
                qk = true;
                dq = Convert.ToDecimal(textBox1.Text);
                if (textBox2.Text == "")
                {
                    jieguo = Convert.ToDecimal(textBox1.Text);
                    textBox2.Text = textBox1.Text + str;
                    shang = str;
                }
                else
                {
                    js();
                    )
                        textBox2.Text += textBox1.Text + str;
                    else
                        textBox2.Text += "(" + textBox1.Text + ")" + str;
                    textBox1.Text = jieguo.ToString();
                    shang = str;
                }
            }
        }
        //标记是否点击运算符号
        bool qk = false;
        //保存结果
        ;
        ;
        //上一步操作
        string shang = "";
        /// <summary>
        /// 运算符操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void jia_Click(object sender, EventArgs e)
        {
            jis((sender as Control).Text);
        }
        /// <summary>
        /// 根据上一次运算符操作
        /// </summary>
        private void js()
        {
            try {
            switch(shang)
            {
                case "+":
                    jieguo = jieguo + dq;
                    break;
                case "-":
                    jieguo = jieguo - dq;
                    break;
                case "*":
                    jieguo = jieguo * dq;
                    break;
                case "/":
                    jieguo = jieguo / dq;
                    break;
            }

            }
            "; }
        }
        /// <summary>
        /// 等号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button20_Click(object sender, EventArgs e)
        {
            js();
            textBox2.Text = "";
            textBox1.Text = jieguo.ToString();
        }

        private void button20_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch(e.KeyChar)
            {
                case '.':
                    if (!textBox1.Text.Contains("."))
                        textBox1.Text += ".";
                    break;
                case (char)Keys.Back:
                    )
                        textBox1.Text = ";
                    else
                        textBox1.Text = textBox1.Text.Substring(, textBox1.TextLength - );
                    break;
                :
                    js();
                    textBox2.Text = "";
                    textBox1.Text = jieguo.ToString();
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                ':
                    shuru(");
                    break;
                case '+':
                    jis("+");
                    break;
                case '-':
                    jis("-");
                    break;
                case '*':
                    jis("*");
                    break;
                case '/':
                    jis("/");
                    break;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox2.Text = "";
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox1.SelectionStart = textBox1.Text.Length;
            textBox2.SelectionStart = textBox2.Text.Length;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.SelectionStart = textBox1.Text.Length;
        }

一版

WindowsForm菜单工具栏--2016年12月6日的更多相关文章

  1. 2016年12月31日 星期六 --出埃及记 Exodus 21:26

    2016年12月31日 星期六 --出埃及记 Exodus 21:26 "If a man hits a manservant or maidservant in the eye and d ...

  2. 2016年12月30日 星期五 --出埃及记 Exodus 21:25

    2016年12月30日 星期五 --出埃及记 Exodus 21:25 burn for burn, wound for wound, bruise for bruise.以烙还烙,以伤还伤,以打还打 ...

  3. 2016年12月29日 星期四 --出埃及记 Exodus 21:24

    2016年12月29日 星期四 --出埃及记 Exodus 21:24 eye for eye, tooth for tooth, hand for hand, foot for foot,以眼还眼, ...

  4. 2016年12月28日 星期三 --出埃及记 Exodus 21:23

    2016年12月28日 星期三 --出埃及记 Exodus 21:23 But if there is serious injury, you are to take life for life,若有 ...

  5. 2016年12月27日 星期二 --出埃及记 Exodus 21:22

    2016年12月27日 星期二 --出埃及记 Exodus 21:22 "If men who are fighting hit a pregnant woman and she gives ...

  6. c++中变量声明和变量定义的区别。2016年12月6日

    整个流程: 1.程序告诉cpu,程序将要使用一个变量.(暂时不一定用到,先说一下.) 2.程序告诉CPU,程序现在就要使用一个变量.(现在就用) 3.cpu按照这个变量的类型,把内存划分出几个单位(b ...

  7. 2016年12月26日 星期一 --出埃及记 Exodus 21:21

    2016年12月26日 星期一 --出埃及记 Exodus 21:21 but he is not to be punished if the slave gets up after a day or ...

  8. 2016年12月25日 星期日 --出埃及记 Exodus 21:20

    2016年12月25日 星期日 --出埃及记 Exodus 21:20 "If a man beats his male or female slave with a rod and the ...

  9. 2016年12月24日 星期六 --出埃及记 Exodus 21:19

    2016年12月24日 星期六 --出埃及记 Exodus 21:19 the one who struck the blow will not be held responsible if the ...

随机推荐

  1. 解决ppt中视频不能播放的问题

    小伙伴一直在纠结一个问题,有个ppt,在其他人的电脑上可以正常播放其中的视频,但是在某一个电脑上却总是不能播放,一直没找到原因,俺们今早捯饬了一下,貌似找到一丢丢原因和解决办法了. #1,疑似原因 为 ...

  2. linux-windows资源共享

    先安装samba,然后 sudo mount -t cifs //192.168.1.111/Jack_Win_Share /media/ -o username=Jack,password=1,io ...

  3. jquery鼠标右键事件

    $('body').live("mousedown",function(e){ $('body').bind("contextmenu",function(e) ...

  4. C#基础系列——委托实现简单设计模式

    前言:上一篇介绍了下多线程的相关知识:C#基础系列——多线程的常见用法详解,里面就提到了委托变量.这篇简单介绍下委托的使用.当然啦,园子里面很多介绍委托的文章都会说道:委托和事件的概念就像一道坎,过了 ...

  5. UML——在Visual Studio 2013/2015中设计UML类图

    1.UML简介 Unified Modeling Language (UML)又称统一建模语言或标准建模语言. 简单说就是以图形方式表现模型,根据不同模型进行分类,在UML 2.0中有13种图,以下是 ...

  6. 【JSON】JavaScript删除json元素

    1.json中的两种结构:对象{}和数组[] 2.直接delete json对象[元素名称].

  7. Java学习笔记-多线程-创建线程的方式

    创建线程 创建线程的方式: 继承java.lang.Thread 实现java.lang.Runnable接口 所有的线程对象都是Thead及其子类的实例 每个线程完成一定的任务,其实就是一段顺序执行 ...

  8. python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'如何解决

    python3中用HTMLTestRunner.py报ImportError: No module named 'StringIO'的解决方法: 1.原因是官网的是python2语法写的,看官手动把官 ...

  9. Codeforces Round #373 (Div. 2)

    A,B,C傻逼题,就不说了. E题: #include <iostream> #include <cstdio> #include <cstring> #inclu ...

  10. R语言排序:sort(),rank(),order()示例

    > x<-c(97,93,85,74,32,100,99,67) > sort(x) [1] 32 67 74 85 93 97 99 100 > order(x) [1] 5 ...