WindowsForm菜单工具栏--2016年12月6日
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日的更多相关文章
- 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 ...
- 2016年12月30日 星期五 --出埃及记 Exodus 21:25
2016年12月30日 星期五 --出埃及记 Exodus 21:25 burn for burn, wound for wound, bruise for bruise.以烙还烙,以伤还伤,以打还打 ...
- 2016年12月29日 星期四 --出埃及记 Exodus 21:24
2016年12月29日 星期四 --出埃及记 Exodus 21:24 eye for eye, tooth for tooth, hand for hand, foot for foot,以眼还眼, ...
- 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,若有 ...
- 2016年12月27日 星期二 --出埃及记 Exodus 21:22
2016年12月27日 星期二 --出埃及记 Exodus 21:22 "If men who are fighting hit a pregnant woman and she gives ...
- c++中变量声明和变量定义的区别。2016年12月6日
整个流程: 1.程序告诉cpu,程序将要使用一个变量.(暂时不一定用到,先说一下.) 2.程序告诉CPU,程序现在就要使用一个变量.(现在就用) 3.cpu按照这个变量的类型,把内存划分出几个单位(b ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- SVN Files 的值“ < < < < < < < .mine”无效。路径中具有非法字符。
错误 1 Files 的值“ < < < < < < < .mine”无效.路径中具有非法字符. 今天使用SVN进行更新的时候,出现了如上问题,想起卓 ...
- ASP.NET WebForm中异步请求防止XSRF攻击的方法
在ASP.NET MVC中微软已经提供了如何防止跨域攻击的方法.对于传统Webfrom中使用Handler来接受ajax的Post请求数据,如何来防止XSRF攻击呢.这里给大家提供一个简单地方法,和M ...
- iOS中多线程常用的知识点
1.pThread 跨平台的多线程技术 , 是IEEE制定的POSIX 表示可移植性操作系统接口的多线程计数,UNIX内核平台 Unix,Linux,Mac(小红帽) (windows上有可移 ...
- 快速上手php:使用PhpStrom部署项目
闲话 上学的时候一直以为可以专注自己的领域,以为与php无缘的,但是这种想法是错误,在完成任务的时候,你不得不使用你不熟悉的语言或者框架.正所谓业务驱动开发,这次接手已经离职的前辈的留下来的项目,最蛋 ...
- BZOJ 1503: [NOI2004]郁闷的出纳员
1503: [NOI2004]郁闷的出纳员 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 10526 Solved: 3685[Submit][Stat ...
- unsigned无符号、有符号类型的符号拓展
先看一段代码 #include <stdio.h> main(){ unsigned ; char b = a; printf("%d %d",a,b); ; } a输 ...
- Zabbix使用点滴
Application --> Items --> Triggers 1.磁盘柜日志输出至Rsyslog服务器,Zabbix抓取:System-Syslogsystem-log(log[/ ...
- <<< jquery简介、开头语法、在线开发手册
简介 jQuery是一个兼容多浏览器的javascript框架,核心理念是write less,do more(写得更少,做得更多).jQuery在2006年1月由美国人John Resig在纽约的b ...
- 介绍对称加密算法,最常用的莫过于DES数据加密算法
DES DES-Data Encryption Standard,即数据加密算法.是IBM公司于1975年研究成功并公开发表的.DES算法的入口参数有三个:Key.Data.Mode.其中Key为8个 ...
- PHP解决抢购、秒杀、抢楼、抽奖等阻塞式高并发库存防控超量的思路方法
如今在电商行业里,秒杀抢购活动已经是商家常用促销手段.但是库存数量有限,而同时下单人数超过了库存量,就会导致商品超卖甚至库存变负数的问题. 又比如:抢购火车票.论坛抢楼.抽奖乃至爆红微博评论等也会引发 ...