Home > Net >  DataGridView binding List, show only the need of columns
DataGridView binding List, show only the need of columns

Time:04-13

According to the online content, has realized the binding list and display,

Now I have a lot of items in a list, but I just want to show a few items,

Do not use the specified attribute of public {get; }, because this list there are other role,

What is your code?

Public class DC
{
Public int a {get; }
Public int b {get; }
Public bool show the {get; }
Public DC (int ac, int BC)
{
A=ac;
B=BC;
The show=true;
}
}

List BindList=new List (a);
BindingList Lists=new BindingList (BindList);
DataGridViewDemo. The DataSource=lists;

Now I just want to show and show a, b, don't want him, according to do?
DataGridViewDemo. AutoGenerateColumns=false; Has been set to false

CodePudding user response:

WPF is?
https://github.com/xiejiang2014/DataGrid-Attribute
See the DoNotAutoGenerateDataGridColumnAttribute
  •  Tags:  
  • C#
  • Related