using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DataGridView1224
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
BindingList<Student> list = new BindingList<Student>();
private void Form1_Load(object sender, EventArgs e)
{
list.Add(new Student() { Age = 10, Name = "zs" });
list.Add(new Student() { Age = 20, Name = "zs2" });
list.Add(new Student() { Age = 30, Name = "zs3" });
list.Add(new Student() { Age = 40, Name = "zs4" });
list.Add(new Student() { Age = 50, Name = "zs5" });
dataGridView1.DataSource = list;
}
private void button1_Click(object sender, EventArgs e)
{
list.Clear();
}
}
public class Student
{
public int Age { get; set; }
public string Name { get; set; }
}
}