C
C#3mo ago
Shogunex

How to hide Id column from the sqlite db (DataGrid)

I was searching how to hide the Id column whenever i put the db as the item source. I saw a guide on youtube but he was using listview and I couldn't replicate it on my DataGrid. I tried using
CitizenDataGrid.Columns[0].Visibility = Visibility.Collapsed;
CitizenDataGrid.Columns[0].Visibility = Visibility.Collapsed;
but it keeps on giving an error. This is the code for showing my db in the DataGrid
public SearchDatabase()
{
InitializeComponent();

CitizenDataContext context = new CitizenDataContext();

testingCitizen = new ObservableCollection<Citizen>(context.Citizens.ToList());

CitizenDataGrid.ItemsSource = testingCitizen;
//CitizenDataGrid.Columns[0].Visibility = Visibility.Collapsed;


}
public SearchDatabase()
{
InitializeComponent();

CitizenDataContext context = new CitizenDataContext();

testingCitizen = new ObservableCollection<Citizen>(context.Citizens.ToList());

CitizenDataGrid.ItemsSource = testingCitizen;
//CitizenDataGrid.Columns[0].Visibility = Visibility.Collapsed;


}
This is the output of the code
No description
0 Replies
No replies yetBe the first to reply to this messageJoin