DataGridView and System.ComponentModel attributes
-
Hi All, This is Windows Forms, not web. I've got a class, who's properties are normally exposed to my users in a PropertyGrid control. Some of the properties have attributes from the System.ComponentModel namespace to hide, force read only, or rename attributes (DisplayName, ReadOnly, Browsable etc). Now, for some users (those with a superuser access), I need to expose some of the hidden properties, in a DataGridView. But the attributes are causing problems... When I bind a DataGridView to a List of my objects, only the columns shown in the PropertyGrid are shown. Even if I disable automatic column generation, and try to manually create columns, like this:-
dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = _my List_; DataGridViewColumn column = new DataGridViewTextBoxColumn(); column.Name = "Column Name"; column.DataPropertyName = "HiddenProperty"; dataGridView1.Columns.Add(column);
The created column simply comes out blank. Does anyone know a way round this? Other than (of course) losing the databinding functionality and filling the DataGridView manually? Thanks Jon
using System.Beer;
-
Hi All, This is Windows Forms, not web. I've got a class, who's properties are normally exposed to my users in a PropertyGrid control. Some of the properties have attributes from the System.ComponentModel namespace to hide, force read only, or rename attributes (DisplayName, ReadOnly, Browsable etc). Now, for some users (those with a superuser access), I need to expose some of the hidden properties, in a DataGridView. But the attributes are causing problems... When I bind a DataGridView to a List of my objects, only the columns shown in the PropertyGrid are shown. Even if I disable automatic column generation, and try to manually create columns, like this:-
dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = _my List_; DataGridViewColumn column = new DataGridViewTextBoxColumn(); column.Name = "Column Name"; column.DataPropertyName = "HiddenProperty"; dataGridView1.Columns.Add(column);
The created column simply comes out blank. Does anyone know a way round this? Other than (of course) losing the databinding functionality and filling the DataGridView manually? Thanks Jon
using System.Beer;
Hi Jon This is just a shot in the dark, but have you looked into AttributeProvider[^]?
Tech, life, family, faith: Give me a visit. I'm currently blogging about: How could God prove Himself to humanity? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango