How to display and remove columns in a data grid?

Hi,
I created checkboxes each of which displays a column name from an already created table. I added an empty data grid to display only the columns that I check their names in the checkboxes. However, the columns that are created in the data grid are just headers without data.

My code is quite messy because I have been trying different methods that didn’t seem to work and this why I didn’t share it.

So, my question is: how to populate my data grid with full columns—not just their headers— after I check their names in the checkboxes and remove them from the data grid after unchecking the checkboxes?

Welcome to the Forum!

Data Grids work best with Data Binding. Neither topic is quite trivial, but there are some great Tutorials on the subject!

I’d walk through the appropriate Tutorials, and get a feel for how the working parts fit together.

2 Likes

Thank you for your reply. I’ll try Data Binding as per your recommendation and hopefully, it works for me.