I created a custom component DataGridView, inside which there is a standard DataGridViewImageColumn. The new property changes the visibility of the column when I do not need a separate table. I add a column to the constructor and update it on the CellFormatting event. This is the part that works as intended.
When I drop the control into a new form, it appears with a new column in it. Running the program results in two columns of images in the grid.

The new form just added a component and installed Dock.Fill

When I start it without changing anything, it shows me two columns. The first works as it should, and the second always shows the missing x-image (without data in it, so that they display as x).
ne, .
private CustomDataGridView customDataGridView1;
private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1;
, , VS . , DGV.Columns.
VS ?
.
public class CustomDataGridView : DataGridView
{
private DataGridViewImageColumn EditStatusIcons;
private bool hasIcons = true;
public bool HasIcons
{
get { return this.hasIcons; }
set
{
if (this.Columns["EditIcons"] == null) return;
this.Columns["EditIcons"].Visible = value;
this.hasIcons = value;
}
}
public CustomDataGridView()
{
this.EditStatusIcons = new System.Windows.Forms.DataGridViewImageColumn();
this.EditStatusIcons.HeaderText = "";
this.EditStatusIcons.Name = "EditStatusIcons";
this.Columns.Add(this.EditStatusIcons);
}
}
: this.AutoGenerateColumns = false;, DataGridView , . .
dataGridViewImageColumn1, .