我正在尝试用C#完成一堂作业课。我应该向Datagrid视图控件添加一个数据源。但是,在Sharp Develop中的公共任务菜单下,数据源对话框无法添加DataSource。
这显然与VS的工作原理不同。有人能帮我弄清楚如何在SharpDevelop中做到这一点吗?
发布于 2009-02-26 10:45:08
您可以使用显式绑定以编程方式添加数据源。例如,在FormLoad事件期间(引入显式BindingSource):
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.BindingSource bindingSource1;
private System.Data.DataSet dataSet1;
private System.Windows.Forms.Label label1;
//...
private void Form1_Load(object sender, EventArgs e)
{
this.dataSet1.ReadXml("x2.xml");
this.label1.Text = dataSet1.Tables[0].TableName;
this.bindingSource1.DataSource = dataSet1.Tables[0];
this.dataGridView1.DataSource = bindingSource1;
}https://stackoverflow.com/questions/589914
复制相似问题