I have a very simple app with the DataGridView which has bindingSource assigned to its DataSource property. bindingSource is a BindingSource type which has a Data assigned to its DataSource property. Data has just one property ‘string[] files’. The problem is that when I try to select columns to be displayed, using Visual Designer the ‘Selected Columns’ is empty. Why? I can't attached the zip file of the tiny project created by Visual Studio 2017 so I am providing the code:
namespace WindowsFormsAppTest
{
class Data
{
private string[] files;
public string[] Files { get => files; set => files = value; }
}
}
using System;
using System.Windows.Forms;
namespace WindowsFormsAppTest
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.
</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region "business object"
#endregion
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.DataSource = this.bindingSource;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.Size = new System.Drawing.Size(800, 450);
this.dataGridView.TabIndex = 1;
//
// bindingSource
//
this.bindingSource.DataSource = typeof(WindowsFormsAppTest.Data);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.dataGridView);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private BindingSource bindingSource;
}
}
Regards,
Janusz