0
votes

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?

2

2 Answers

1
votes

Use

[System.ComponentModel.Browsable(false)]
public int SomeProperty{get;set;}

in your class.

1
votes

Yes, set AutoGenerateColumns = false, then manually populate columns. or use Browsable(false) attribute in columns which you don't want to show.