winform
Posted 右掱写爱
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了winform相关的知识,希望对你有一定的参考价值。
WinForm: 客户端应用程序; ------------------------------------------------------- 小恶作剧:
FormBorderSt----None-----无边框 TopMost----True--------最上层 ShowlnTaskbar----False----任务栏不出现 Opacity-----1%-----透明度1% WindowState----Maxinmized-----初始最大化
----------------------------------------------------------- 布局: StartPosition --开始位置 Manual --无任何位置设置,根据Location的位置开始 CenterScreen --屏幕居中显示,覆盖Location的效果 WindowsDefaultLocation --默认位置,覆盖Location的效果
Location --窗体启动时的位置
MaximumSize --最大尺寸 MinimumSize --最小尺寸 Size --窗体默认尺寸
WindowState --窗体开启时的状态 ---------------------------------------------------------- 窗口样式: ControlBox --是否有右上角最小化,最大化,关闭按钮 HelpButton --右上角是否显示帮助按钮,需要派和最大化最小化按钮显示隐藏使用 Icon --右上角小图标,ico类型的图片 IsMdiContainer --是否是MDI容器 MaximizeBox --是否显示最大化按钮 MinimizeBox --是否显示最小化按钮 Opacity --窗体透明度,最小1% ShowIcon --是否显示小图标 ShowInTaskbar --是否显示在任务栏中 SizeGripStyle --何时显示窗体拉伸手柄(鸡肋) TopMost --是否在最顶部,置顶 TransparencyKey --窗体上要透明显示的颜色 ---------------------------------------------------------- 行为: ContextMenuStrip --用户右键显示的菜单 ---------------------------------------------------------- 焦点: ---------------------------------------------------------- 可访问性: ---------------------------------------------------------- 设计: Name --窗体名称,后台调取时使用 ---------------------------------------------------------- 数据: Tag --可以放任意内容的好属性 ---------------------------------------------------------- 外观: BackColor --背景颜色 BackGroundImage --背景图片 BackGroundImage --背景图片排列格式 Cursor --鼠标进入该控件的样式 Font --字体样式 ForeColor --字体颜色 FormBorderStyle --窗体边框样式,有无边框,是否可以拉伸等效果 Text --窗体右上角名称 ---------------------------------------------------------- 杂项: AcceptButton --设置一个按钮,用户在当前窗体按回车就相当于按了这个按钮 CancelButton --设置一个按钮,用户在当前窗体按ESC就相当于按了这个按钮
计算器:
1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms; 10 11 namespace _6._26 12 { 13 public partial class 计算 : Form 14 { 15 public 计算() 16 { 17 InitializeComponent(); 18 } 19 20 private void b0_Click(object sender, EventArgs e) 21 { 22 textBox2.Text +="0"; 23 } 24 25 private void b1_Click(object sender, EventArgs e) 26 { 27 textBox2.Text += "1"; 28 } 29 30 private void b2_Click(object sender, EventArgs e) 31 { 32 textBox2.Text += "2"; 33 } 34 35 private void b3_Click(object sender, EventArgs e) 36 { 37 textBox2.Text += "3"; 38 } 39 40 private void b4_Click(object sender, EventArgs e) 41 { 42 textBox2.Text += "4"; 43 } 44 45 private void b5_Click(object sender, EventArgs e) 46 { 47 textBox2.Text += "5"; 48 } 49 50 private void b6_Click(object sender, EventArgs e) 51 { 52 textBox2.Text += "6"; 53 } 54 55 private void b7_Click(object sender, EventArgs e) 56 { 57 textBox2.Text += "7"; 58 } 59 60 private void b8_Click(object sender, EventArgs e) 61 { 62 textBox2.Text += "8"; 63 } 64 65 private void b9_Click(object sender, EventArgs e) 66 { 67 textBox2.Text += "9"; 68 } 69 70 private void bdian_Click(object sender, EventArgs e) 71 { 72 textBox2.Text += "."; 73 } 74 75 double a, b,c; //a---1;b---2 第一个数a;第二个数b 76 string m; //运算符 77 78 //------------------------------------------------- 79 private void bjia_Click(object sender, EventArgs e)//+ 80 { 81 82 if (textBox1.Text == "") -----textBox1为空时 83 { 84 a = Convert.ToDouble(textBox2.Text); //a是+前的数字 85 m = "+"; //m是运算符 86 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 87 textBox2.Text = ""; //textBox2清空 88 } 89 else ------textBox1不为空时 90 { 91 92 //执行!!!!! 93 c = Convert.ToDouble(textBox2.Text); //textBox2的数字 94 95 switch (m) 96 { 97 case ("+"): 98 textBox2.Text = Convert.ToString(a + c); 99 a = Convert.ToDouble(textBox2.Text); 100 break; 101 case ("-"): 102 textBox2.Text = Convert.ToString(a - c); 103 a = Convert.ToDouble(textBox2.Text); 104 break; 105 case ("*"): 106 textBox2.Text = Convert.ToString(a * c); 107 a = Convert.ToDouble(textBox2.Text); 108 break; 109 case ("/"): 110 textBox2.Text = Convert.ToString(a / c); 111 a = Convert.ToDouble(textBox2.Text); 112 break; 113 } 114 m = "+"; //m是运算符 115 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 116 textBox2.Text = ""; //textBox2清空 117 } 118 119 } 120 121 private void jian_Click(object sender, EventArgs e)//- 122 { 123 if (textBox1.Text == "") 124 { 125 a = Convert.ToDouble(textBox2.Text); //a是-前的数字 126 m = "-"; //m是运算符 127 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 128 textBox2.Text = ""; //textBox2清空 129 } 130 else 131 { 132 133 //执行!!!!! 134 c = Convert.ToDouble(textBox2.Text); //textBox2的数字 135 136 switch (m) 137 { 138 case ("+"): 139 textBox2.Text = Convert.ToString(a + c); 140 a = Convert.ToDouble(textBox2.Text); 141 break; 142 case ("-"): 143 textBox2.Text = Convert.ToString(a - c); 144 a = Convert.ToDouble(textBox2.Text); 145 break; 146 case ("*"): 147 textBox2.Text = Convert.ToString(a * c); 148 a = Convert.ToDouble(textBox2.Text); 149 break; 150 case ("/"): 151 textBox2.Text = Convert.ToString(a / c); 152 a = Convert.ToDouble(textBox2.Text); 153 break; 154 } 155 m = "-"; //m是运算符 156 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 157 textBox2.Text = ""; //textBox2清空 158 } 159 } 160 161 private void cheng_Click(object sender, EventArgs e) //* 162 { 163 if (textBox1.Text == "") 164 { 165 a = Convert.ToDouble(textBox2.Text); //a是*前的数字 166 m = "*"; //m是运算符 167 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 168 textBox2.Text = ""; //textBox2清空 169 } 170 else 171 { 172 173 //执行!!!!! 174 c = Convert.ToDouble(textBox2.Text); //textBox2的数字 175 176 switch (m) 177 { 178 case ("+"): 179 textBox2.Text = Convert.ToString(a + c); 180 a = Convert.ToDouble(textBox2.Text); 181 break; 182 case ("-"): 183 textBox2.Text = Convert.ToString(a - c); 184 a = Convert.ToDouble(textBox2.Text); 185 break; 186 case ("*"): 187 textBox2.Text = Convert.ToString(a * c); 188 a = Convert.ToDouble(textBox2.Text); 189 break; 190 case ("/"): 191 textBox2.Text = Convert.ToString(a / c); 192 a = Convert.ToDouble(textBox2.Text); 193 break; 194 } 195 m = "*"; //m是运算符 196 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 197 textBox2.Text = ""; //textBox2清空 198 } 199 } 200 201 private void chu_Click(object sender, EventArgs e) // / 202 { 203 if (textBox1.Text == "") 204 { 205 a = Convert.ToDouble(textBox2.Text); //a是/前的数字 206 m = "/"; //m是运算符 207 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 208 textBox2.Text = ""; //textBox2清空 209 } 210 else 211 { 212 213 //执行!!!!! 214 c = Convert.ToDouble(textBox2.Text); //textBox2的数字 215 216 switch (m) 217 { 218 case ("+"): 219 textBox2.Text = Convert.ToString(a + c); 220 a = Convert.ToDouble(textBox2.Text); 221 break; 222 case ("-"): 223 textBox2.Text = Convert.ToString(a - c); 224 a = Convert.ToDouble(textBox2.Text); 225 break; 226 case ("*"): 227 textBox2.Text = Convert.ToString(a * c); 228 a = Convert.ToDouble(textBox2.Text); 229 break; 230 case ("/"): 231 textBox2.Text = Convert.ToString(a / c); 232 a = Convert.ToDouble(textBox2.Text); 233 break; 234 } 235 m = "/"; //m是运算符 236 textBox1.Text = textBox2.Text + m; //textBox1.Text中显示 237 textBox2.Text = ""; //textBox2清空 238 } 239 } 240 241 private void deng_Click(object sender, EventArgs e) // = 242 { 243 //执行!!!!! 244 b = Convert.ToDouble(textBox2.Text); //d是=前的数字 245 switch (m) 246 { 247 case ("+"): ---加法时执行加法 248 textBox2.Text = Convert.ToString(a + b); 249 textBox1.Text = ""; ---清空textBox1 250 break; 251 case ("-"): 252 textBox2.Text = Convert.ToString(a - b); 253 textBox1.Text = ""; 254 break; 255 case ("*"): 256 textBox2.Text = Convert.ToString(a * b); 257 258 textBox1.Text = ""; 259 break; 260 case ("/"): 261 textBox2.Text = Convert.ToString(a / b); 262 textBox1.Text = ""; 263 break; 264 } 265 } 266 267 private void C_Click(object sender, EventArgs e) 268 { 269 textBox2.Text = ""; 270 textBox1.Text = ""; 271 } 272 273 private void Da_Click(object sender, EventArgs e) 274 { 275 //删除追后一个数字 276 string q=textBox2.Text; 277 q = q.Substring(0, q.Length - 1); //Substring 截取字符串长度 ,Length 截取当前字符串长度 278 textBox2.Text = q; 279 } 280 } 281 }
以上是关于winform的主要内容,如果未能解决你的问题,请参考以下文章
winform定时运行怎么做,比如每天12点的时候执行一段代码