Reputation: 2060
I have a DataGridView and I'm binding it directly to a generic List of a custom class, no BindingSource intermediary. This custom class has a number of public properties and I want my dataGridView to display only some of those properties.
I've created datagridview columns for the custom class properties I'm interested in, and set their DataPropertyName
to the class properties names. But the gridview fetches all the properties from its source and displays them.
Is there anyway to display only those properties I'm interested in?
Upvotes: 0
Views: 519
Reputation: 73492
Yes, set AutoGenerateColumns = false, then manually populate columns. or use
Browsable(false)
attribute in columns which you don't want to show.
Upvotes: 1
Reputation: 3255
Use
[System.ComponentModel.Browsable(false)]
public int SomeProperty{get;set;}
in your class.
Upvotes: 1