I've got a class with two public properties, Name and Text. I want to bind a DataGridView to a list of these objects, so I loaded them into a BindingList<>. I only want to show the Name property in the DataGridView, but I'm getting both columns. What am I doing wrong?
private void fileOpenTextBox1_FileSelected(object sender, string e)
{
m_definitions = new BindingList<TagSimDefinition>(TagSimDefinition.Read(e));
dgvTagNames.AutoGenerateColumns = false;
dgvTagNames.Columns.Clear();
DataGridViewCell cell = new DataGridViewTextBoxCell();
DataGridViewTextBoxColumn colTagName = new DataGridViewTextBoxColumn()
{
CellTemplate = cell,
Name = "colTagName",
HeaderText = "Tag Name",
DataPropertyName = "Name"
};
dgvTagNames.Columns.Add(colTagName);
dgvTagNames.DataSource = m_definitions;
}