So I have a TreeView in GTK# and I preload it with an empty TreeModelSort (no columns.)
At runtime I let the users select the columns they'd like to add and when the button is clicked I create a new ListStore with these columns, from that I create a TreeModelFilter and TreeModelSort. I then append the values to that TreeModelSort by using reflection to pick up correct values based on columns. That all works fine and I end up with a TreeModelSort with the columns and data I am interested in.
The problem arises when I try to replace the old TreeView.Model with the new one I've just created. There are no exceptions and it replaces it fine but the new columns and data don't show up in the table.
Any ideas on what I could be missing?
Is what I'm trying to allowed or do I need to remove the TreeView from the screen and replace it with a new one?
Edit: Or even if I could have all columns in the list store but only show a few selected ones in the TreeView, is that possible? All the tutorials I've found have exact one to one mapping of columns between ListStore and TreeView. Any ideas?
(no experience with GTK#, but lots of experience with gtk in other languages). It seems to me you might be mixing views and models here. To make columns visible in a view, you not only need to have them in your model (as you are doing), but you also need to add cell rendered to your view, binding them with specific columns in your model. I'll show some pseudo-code below, and let you convert to gtk#:
add attribute to the renderer, for instance to tell it which column of your model it should render. For instance: gtk_cell_layout_add_attribute(column, renderer, "text", 0)
to show the first column of your model (interpreted as text)
In fact, I would not implement customizable columns the way you do. Instead, I would have, from the start, a model that contains all possible columns and their values. Then when the user choses which columns to display, I would add (or remove) cell renderers and/or GtkTreeViewColumns from the view.
One of the benefits is that you could have several views of the same model, each displaying a different set of columns.