Grid Columns

  • Thread starter Thread starter David McCallum
  • Start date Start date
D

David McCallum

Given the code below, what changes are needed to show only the current and
name fields on the grid, also to show the Boolean field as a checkbox.

TIA

David McCallum

class Person{
public int ID { get; set; }
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
public bool Current { get; set; }
}

public MyForm()
{
InitializeComponent();
List<Person> sessions=new List<Person>
{
new Person()
{
ID = 1,
Name = "person",
DateOfBirth =
DateTime.Now,
Current = true
}
};

}
 
You might want to take a look at the property DataGrid.TableStyles as
well as the classes DataGridTableStyle and DataGridColumnStyle. You
use the latter to detemine which columns are visible.

To display a checkbox column, you have to create your own
DataGridColumnStyle which draws a checkbox. I am currently working at
this, so if you remind me again in a couple of days I can give you my
solution for this.
 
Back
Top