关于List泛型为什么绑定到DataGridView显示不了数据的问题
下列代码中,为什么显示不了数据,如何修改呢。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<User> list = new List<User>();
for (int i = 0; i < 100; i++)
{
User u = new User();
u.id = i;
u.weburl = "http://www.baidu.com";
u.logintype = "uid";
u.username = "baidu";
u.password = "123456789";
u.datetime = DateTime.Now.ToString("hh:mm:ss");
u.content = "建设中...";
list.Add(u);
}
this.DataGridView_User.DataSource = new BindingList<User>(list);
//this.DataGridView_User.DataSource = list;
}
private void button1_Click(object sender, EventArgs e)
{
}
}
public class User
{
public int id;
public string weburl;
public string logintype;
public string username;
public string password;
public string datetime;
public string content;
}
public class User
{
public int id { get; set; }
public string weburl { get; set; }
public string logintype { get; set; }
public string username { get; set; }
public string password { get; set; }
public string datetime { get; set; }
public string content { get; set; }
}