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 ...
随机推荐
- jquery的add()用法总结
<!DOCTYPE html> <html> <head lang="en"> <meta charset="utf-8&quo ...
- Windows Serivce服务实现过程和打包安装
环境:vs2013,win7 参考: Windows服务的快速搭建与调试(C#图解) .Net实现Windows服务安装完成后自动启动的两种方法 C# 生成windows 服务打包程序 1.新建项目W ...
- Netron开发快速上手(二):Netron序列化
Netron是一个C#开源图形库,可以帮助开发人员开发出类似Visio的作图软件.本文继前文”Netron开发快速上手(一)“讨论如何利用Netron里的序列化功能快速保存自己开发的图形对象. 一个用 ...
- python 环境搭建
python下载地址: 进入https://www.python.org/download/releases/3.3.4/,下载Windows X86-64 MSI Installer (3.3.4) ...
- 延迟容忍网络(Delay-tolerant networking)
标签: 网络networking存储工作network路由器 2012-03-24 10:01 3702人阅读 评论(0) 收藏 举报 分类: 计算机网络(12) 版权声明:本文为博主原创文章,对文章 ...
- 特征检测(feature detection)的一些资料
FAST特征点: http://blog.csdn.net/hujingshuang/article/details/46898007 BRIEF特征描述子: http://blog.csdn.net ...
- CSS备忘录
1, 浮动框(float)会使得元素脱离文档流, 因此不占用文档空间; 因此当一个Div的子元素都为float时会导致该Div高度为0, 这一问题称为"高度塌陷" 为了解决这个问题 ...
- BZOJ 2743: [HEOI2012]采花
2743: [HEOI2012]采花 Time Limit: 15 Sec Memory Limit: 128 MBSubmit: 2056 Solved: 1059[Submit][Status ...
- js-JavaScript高级程序设计学习笔记21 改善JavaScript性能的方法
第24章 最佳实践 1.性能 1.避免全局查找 将在一个函数中会用到多次的全局对象保存在局部变量.比如多次使用document.getElement...,可以首先var doc=document,把 ...
- 七牛图片上传JSSDK
BASE64图片上传 接口说明: POST /putb64/<Fsize>/key/<EncodedKey>/mimeType/<EncodedMimeType>/ ...