winfrom绘制渐变 / 调用浏览器访问指定地址
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {//绘制渐变色背景 Graphics g = e.Graphics; System.Drawing.Drawing2D.LinearGradientBrush MyBrush =new System.Drawing.Drawing2D.LinearGradientBrush( this.ClientRectangle,Color.Black, Color.Yellow, System.Drawing.Drawing2D.LinearGradientMode.Vertical); g.FillRectangle(MyBrush, this.ClientRectangle); } private void Form1_Resize(object sender, System.EventArgs e) {//缩放窗口时更新背景 this.Refresh(); }
效果图:
调用浏览器访问指定地址:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process ps = new System.Diagnostics.Process(); System.Windows.Forms.LinkLabel linkLabel = (System.Windows.Forms.LinkLabel)sender; ps.StartInfo.FileName = "iexplore.exe"; ps.StartInfo.Arguments = linkLabel.Text; ps.Start(); }