I am attempting to complete a homework lesson in C#. I am supposed to add a datasource to a Datagrid view control. However, in Sharp Develop under the common task menu the datasource dialog has no way to add a DataSource.
This apparently is different than how VS works. Can someone help me figure out how to do this in SharpDevelop?
You can add the datasource programatically, using explicit binding. For example, during the FormLoad
event (introducing an explicit 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;
}