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 ...
随机推荐
- 国内外前端(js)开发框架对比
国内外前端开发框架对比 首先我们先对目前国内外主流前端开发框架做一个基本的了解,之后再对他们进行一个直观的对比. Bootstrap Bootstrap(http://www.bootcss.com) ...
- 记录android显示流程
mtk平台: displayclient->deque->数据放入显存->surfaceflinger->分发数据到surfacetexture(OnFrameAvailabl ...
- 新书《编写可测试的JavaScript代码 》出版,感谢支持
本书介绍 JavaScript专业开发人员必须具备的一个技能是能够编写可测试的代码.不管是创建新应用程序,还是重写遗留代码,本书都将向你展示如何为客户端和服务器编写和维护可测试的JavaScript代 ...
- flask+sqlite3+echarts3+ajax 异步更新数据
结构: /www | |-- /static |....|-- jquery-3.1.1.js |....|-- echarts.js(echarts3是单文件!!) | |-- /templates ...
- 移动UI设计
移动应用UI设计模式 第二版 导航:跳板式,菜单式,选项卡式(微信)等 表单:登录表单,多步骤表单(递进式),计算表单,搜索表单,长表单等 表格:无表头表格,概览+数据型表格等 搜索:隐式搜索(滴滴打 ...
- ORACLE 导入导出
数据导出:1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中exp system/manager@TEST file=d:\daochu.dmp ...
- Matplotlib 学习笔记
注:该文是上了开智学堂数据科学基础班的课后做的笔记,主讲人是肖凯老师. 数据绘图 数据可视化的原则 为什么要做数据可视化? 为什么要做数据可视化?因为可视化后获取信息的效率高.为什么可视化后获取信息的 ...
- PHPExcel读取excel文件
<?php set_time_limit(0); $dir = dirname(__FILE__);//当前脚本所在路径 require $dir."/PHPExcel_1.8.0/C ...
- Android,不小心关闭了某个小窗口怎么恢复,方法介绍
Window > Show View > Other 需要哪个窗口就用哪个~
- 【BZOJ-3195】奇怪的道路 状压DP (好题!)
3195: [Jxoi2012]奇怪的道路 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 305 Solved: 184[Submit][Statu ...