DataGridView控件可以通過以下方式綁定數據:
dataGridView.DataSource = dataTable;
dataGridView.Rows.Add("John", "Doe");
dataGridView.Rows.Add();
dataGridView.Rows[0].Cells[0].Value = "John";
dataGridView.Rows[0].Cells[1].Value = "Doe";
public class MyDataSource : IDataSource
{
// 實現接口方法...
}
MyDataSource dataSource = new MyDataSource();
dataGridView.DataSource = dataSource;