Visual Studio is not adding new binding source (data source).
I added the new data source (a reference to a class I built) to the Designer.cs in the InitializeComponent() section.
Visual Studio recognized the data member but not the data source. Why won't it recognize my data source?
I added the following code to the end of the section:
this.CharterManagerbindingSource.DataSource = typeof(Program16.CharterManager);
I don't receive any errors in my code. It's like it doesn't even realize I entered it.
*** I am trying to add a binding source to a form so I can use the data source to auto populate information within the class it is linked to
Charter Manager Class Code
internal class CharterManager
{
#region "Instance Properties"
public List<Charter> CharterList { get; private set; }
#endregion
#region "Constructor"
public CharterManager()
{
CharterList = new List<Charter>();
}
#endregion
#region "Methods"
public void AddCharter(Charter aCharter)
{
CharterList.Add(aCharter);
}
public void AddCharter(string customerName, string yachtType, int yachtSize, decimal charterHours)
{
Charter aCharter = new Charter(customerName, yachtType, yachtSize, charterHours);
CharterList.Add(aCharter);
}
public decimal FindLowestCharterFee()
{
decimal lowest = CharterList[0].CharterFee;
foreach (Charter aCharter in CharterList)
{
if (aCharter.CharterFee < lowest)
{
lowest = aCharter.CharterFee;
}
}
return lowest;
}
public decimal GetAverageCharterFee()
{
return GetTotalCharterFee() / CharterList.Count;
}
public int GetCharterCount(int yachtSize)
{
int count = 0;
foreach (Charter aCharter in CharterList)
{
if (aCharter.YachtSize == yachtSize)
{
++count;
}
}
return count;
}
public decimal GetTotalCharterFee()
{
decimal total = 0;
foreach (Charter aCharter in CharterList)
{
total += aCharter.CharterFee;
}
return total;
CharterManagerGrid.Designer.CS Code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.CharterManagerbindingSource = new System.Windows.Forms.BindingSource(this.components);
this.dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.CharterManagerbindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// CharterManagerbindingSource
//
this.CharterManagerbindingSource.DataMember = "Charter List";
this.CharterManagerbindingSource.DataSource = new Program16.CharterManager();
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(80, 66);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 25;
this.dataGridView1.Size = new System.Drawing.Size(240, 150);
this.dataGridView1.TabIndex = 0;
//
// CharterManagerGrid
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dataGridView1);
this.Name = "CharterManagerGrid";
this.Text = "Charter Manager Grid";
((System.ComponentModel.ISupportInitialize)(this.CharterManagerbindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.BindingSource CharterManagerbindingSource;
private System.Windows.Forms.DataGridView dataGridView1;