Button用户点击时引发事件
Label为控件提供运行时信息或说明性文字
Textbox允许用户输入文本
是否显示该控件
txtContent.Visible = true;显示
txtContent.Visible = false;不显示
获取用户名和密码
string strName = txtName.Text.Trim();
string strPwd = txtPwd.Text.Trim();
MessageBox.Show("登录成功");文本框输出显示
txtPwd.Clear();清楚文本框内容
txtName.Focus();为控件设置焦点
换行
txtContent.WordWrap = true;
取消换行
txtContent.WordWrap = false;
将内容写入文件
File.WriteAllText (path, txtContent.Text.Trim());
pictureBox1.Image = Image.FromFile(path); 返回图片
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; 等比例展示图片
imgs = Directory.GetFiles(path); 获取所有的图片文件的路径
Timer按用户设置的时间间隔引发事件
ComboBox显示一个可编辑的文本框,其中包含一个允许值下拉列表。
cbo.Items获取—个对象,该对象表示此 ComboBox中所含的项的集合。
cbo.SelectedItem 作为当前选定项的对象,如果当前没有选定项,则为null。
int year = DateTime.Now.Year;获取当前的年份
Graphics g = this.CreateGraphics(); CreateGraphics方法用于创建一个与当前窗体或控件关联的图形对象
Graphics g = pictureBox1.CreateGraphics();GDI和图片在一起
Graphics g = Graphics.FromImage(bmp);GDI和位图在一起
DrawString在指定位置并且用指定的Brush和Font对象绘制指定的文本字符串。
Point p = new Point(x,y)初始化指定坐标
void Graphics.DrawString(string s, Font font,Brush brush, PointF point)在指定位置并且用指定的 Brush和Font对象绘制指定的文本字符串。
g.DrawString(strNumber[i].ToString(), new Font(font[r.Next(0, 5)], 12), new SolidBrush(colors[r.Next(0, 5)]), p);
void Graphics.DrawLine(Pen pen,Point pt1, Point pt2)(+3多个重载)绘制─条连接两个Point结构的线。
void Bitmap.SetPixel(int x, int y, Color color)在此 Bitmap中设置指定像素的颜色。
void Control.Invalidate()使控件的整个图面无效并导致重绘控件。