1、编写一个Windows应用程序,实现窗体自上而下,由白色到绿色渐变的背景。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace T1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
int x = this.ClientRectangle.Location.X;
int y = this.ClientRectangle.Location.Y;
int m = this.ClientRectangle.Height / 256;//高度分为256份
for(int i = 255; i>=0; i--)
{
Color c = new Color();
c = Color.FromArgb(i, 255, i);//白色是(255,255,255)绿色(0,255,0)
SolidBrush sb = new SolidBrush(c);