I have a a datagrid that I am binding to class that has some columns marked [Browsable(false)]. These columns are showing up blank. Is there some way to turn this off.
I am not using any autobinding but creating the columns myself and setting the DataPropertyName property.
It took me a really long time to find why they are blank now I'm hoping there is some easy way to show the values in them. The only thing I can think of is to write my own DataGridViewColumn classes and re-implement the binding. Any other ideas?
Here is some code that demonstrates the problem, GridBrowsableProblem is a new form with a DataGridView dropped onto it. When run ProblemProperty has no value.
public partial class GridBrowsableProblem : Form
{
public class ProblemTestClass
{
[Browsable(false)]
public string ProblemProperty { get; set; }
public string AnotherProperty { get; set; }
}
public GridBrowsableProblem()
{
InitializeComponent();
DataGridViewTextBoxColumn column1 = new DataGridViewTextBoxColumn();
column1.DataPropertyName = "ProblemProperty";
DataGridViewTextBoxColumn column2 = new DataGridViewTextBoxColumn();
column2.DataPropertyName = "AnotherProperty";
ProblemTestClass item = new ProblemTestClass();
item.ProblemProperty = "test1";
item.AnotherProperty = "test2";
BindingList<ProblemTestClass> bindingList = new BindingList<ProblemTestClass>();
bindingList.Add(item);
dataGridView1.Columns.Add(column1);
dataGridView1.Columns.Add(column2);
dataGridView1.DataSource = bindingList;
}
}