ContextMenuStrip

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


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


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


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


ToolStripContainer
       帮助ToolStrip布局控件


计算器

  1. /// <summary>
  2. /// 根据点击的控件输入数字
  3. /// </summary>
  4. /// <param name="e"></param>
  5. private void shuru(string str)
  6. {
  7. "||qk){
  8. textBox1.Text = str;
  9. qk = false;
  10. }
  11. else
  12. textBox1.Text += str;
  13. }
  14. /// <summary>
  15. /// 输入数字
  16. /// </summary>
  17. /// <param name="sender"></param>
  18. /// <param name="e"></param>
  19. private void b0_Click(object sender, EventArgs e)
  20. {
  21. shuru((sender as Control).Text);
  22. }
  23. /// <summary>
  24. /// 小数点
  25. /// </summary>
  26. /// <param name="sender"></param>
  27. /// <param name="e"></param>
  28. private void dian_Click(object sender, EventArgs e)
  29. {
  30. if(!textBox1.Text.Contains("."))
  31. textBox1.Text+=".";
  32. }
  33. /// <summary>
  34. /// 退格
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. private void back_Click(object sender, EventArgs e)
  39. {
  40. )
  41. textBox1.Text = ";
  42. else
  43. textBox1.Text = textBox1.Text.Substring(, textBox1.TextLength-);
  44. }
  45. /// <summary>
  46. /// 根据按下的按键键入计算符号
  47. /// </summary>
  48. /// <param name="e"></param>
  49. private void jis(string str)
  50. {
  51. if (qk) {
  52. if (shang != str) {
  53. textBox2.Text = textBox2.Text.Substring(, textBox2.TextLength - ) + str;
  54. shang = str;
  55. }
  56. }
  57. else
  58. {
  59. qk = true;
  60. dq = Convert.ToDecimal(textBox1.Text);
  61. if (textBox2.Text == "")
  62. {
  63. jieguo = Convert.ToDecimal(textBox1.Text);
  64. textBox2.Text = textBox1.Text + str;
  65. shang = str;
  66. }
  67. else
  68. {
  69. js();
  70. )
  71. textBox2.Text += textBox1.Text + str;
  72. else
  73. textBox2.Text += "(" + textBox1.Text + ")" + str;
  74. textBox1.Text = jieguo.ToString();
  75. shang = str;
  76. }
  77. }
  78. }
  79. //标记是否点击运算符号
  80. bool qk = false;
  81. //保存结果
  82. ;
  83. ;
  84. //上一步操作
  85. string shang = "";
  86. /// <summary>
  87. /// 运算符操作
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. private void jia_Click(object sender, EventArgs e)
  92. {
  93. jis((sender as Control).Text);
  94. }
  95. /// <summary>
  96. /// 根据上一次运算符操作
  97. /// </summary>
  98. private void js()
  99. {
  100. try {
  101. switch(shang)
  102. {
  103. case "+":
  104. jieguo = jieguo + dq;
  105. break;
  106. case "-":
  107. jieguo = jieguo - dq;
  108. break;
  109. case "*":
  110. jieguo = jieguo * dq;
  111. break;
  112. case "/":
  113. jieguo = jieguo / dq;
  114. break;
  115. }
  116.  
  117. }
  118. "; }
  119. }
  120. /// <summary>
  121. /// 等号
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void button20_Click(object sender, EventArgs e)
  126. {
  127. js();
  128. textBox2.Text = "";
  129. textBox1.Text = jieguo.ToString();
  130. }
  131.  
  132. private void button20_KeyPress(object sender, KeyPressEventArgs e)
  133. {
  134. switch(e.KeyChar)
  135. {
  136. case '.':
  137. if (!textBox1.Text.Contains("."))
  138. textBox1.Text += ".";
  139. break;
  140. case (char)Keys.Back:
  141. )
  142. textBox1.Text = ";
  143. else
  144. textBox1.Text = textBox1.Text.Substring(, textBox1.TextLength - );
  145. break;
  146. :
  147. js();
  148. textBox2.Text = "";
  149. textBox1.Text = jieguo.ToString();
  150. break;
  151. ':
  152. shuru(");
  153. break;
  154. ':
  155. shuru(");
  156. break;
  157. ':
  158. shuru(");
  159. break;
  160. ':
  161. shuru(");
  162. break;
  163. ':
  164. shuru(");
  165. break;
  166. ':
  167. shuru(");
  168. break;
  169. ':
  170. shuru(");
  171. break;
  172. ':
  173. shuru(");
  174. break;
  175. ':
  176. shuru(");
  177. break;
  178. ':
  179. shuru(");
  180. break;
  181. case '+':
  182. jis("+");
  183. break;
  184. case '-':
  185. jis("-");
  186. break;
  187. case '*':
  188. jis("*");
  189. break;
  190. case '/':
  191. jis("/");
  192. break;
  193. }
  194. }
  195.  
  196. private void button3_Click(object sender, EventArgs e)
  197. {
  198. textBox1.Text = textBox2.Text = "";
  199. }
  200.  
  201. private void textBox2_TextChanged(object sender, EventArgs e)
  202. {
  203. textBox1.SelectionStart = textBox1.Text.Length;
  204. textBox2.SelectionStart = textBox2.Text.Length;
  205. }
  206.  
  207. private void button4_Click(object sender, EventArgs e)
  208. {
  209. textBox1.SelectionStart = textBox1.Text.Length;
  210. }

一版

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. Map接口,Map.Entry,hashMap类,TreeMap类,WeakHashMap。

    Collection接口之前接触过,每次保存的对象是一个对象,但是在map中保存的是一对对象,是以key->value形式保存的. 定义: public interface Map<K,V ...

  2. C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 角色成员功能的改进支持公司加入到角色

    我们公司有1万多个网点,每个网点都可以看成是一个公司,公司对不同的网点有不同的策略,商业逻辑,每个网点的人员也都是在不断变化,全国有接近10万从业人员,当我们设计好业务逻辑程序后,不可能因为这些人员的 ...

  3. 为普通Object添加类似AttachedProperty的属性

    为普通Object添加类似AttachedProperty的属性   周银辉 我们知道,在WPF中对应一个DependencyObject,我们很容易通过AttachedProperty来为类型附加一 ...

  4. haproxy 新手上路

    apache.nginx之类的反向代理(转发)功能,通常只能用于http协议,其它协议就不好使了(注:nginx据说商业版的,支持tcp协议了). haproxy可以弥补这方面的不足,haproxy支 ...

  5. [[其他教程]] 2015年最新版iOS基础视频_最适合初学者入门

    主讲:孙庆虎类型:iOS 适合对象:初学者入门视频介绍:本视频是iOS学院精心录制的免费精华版iOS语言基础视频,该视频特点在于最大程度保证了知识点的完整性,按知识点进行视频录制,每个视频控制在20分 ...

  6. ajax返回值中有回车换行、空格的解决方法分享

    最近在写一个页面,用jquery ajax来实现判断,刚写好测试完全没有问题,过了两天发现出现问题,判断不成了.后来发现所有alert出来的返回值前面都会加若干换行和空格.(至今不明白,同一台电脑,同 ...

  7. knockoutJS学习笔记07:绑定上下文

    所谓绑定上下文就是当前绑定(dat-bind)所使用到的对象(ViewModel).在单个对象绑定的情况下是很容易理解的,但对象可能是复杂的类型,嵌套很多层,这个时候每层都有自己的上下文对象,理解起来 ...

  8. 【平面设计AFTER】读到的设计海报分层法

    来源参考:http://www.uisdc.com/graphic-designer-self-improvement 分层法的三层:“背景层”,“图形层”,“信息层” 1,背景层,一般为纯色,场景, ...

  9. linux基础知识与技能3

    3.2.vi的高级使用* 查找在命令模式下,输入/xxx,就可以查找到xxx * 快速切换行在命令模式下,输入:num,就可以快速切换到num行 * 设置显示行号在命令模式下,输入:set nu,就可 ...

  10. 分布式缓存Redis使用心得

    一.缓存在系统中用来做什么 1. 少量数据存储,高速读写访问.通过数据全部in-momery 的方式来保证高速访问,同时提供数据落地的功能,实际这正是Redis最主要的适用场景. 2. 海量数据存储, ...