0

I use AutoPopulateColumns system to display my structure on DataGrid. is there any propertie's Attribute to show Property on ColumnChooser window, not on the grid?

Thanks.

Artem Makarov
  • 874
  • 3
  • 14
  • 25
  • Which property do u want to show.. Question is not much clear..please elaborate.. – Niranjan Singh Jun 12 '12 at 01:35
  • I need to show my class's property not on the grid, but on ColumnChooser form and I use AutoPopulateColumns, so is there any Attribute like "DisplayName" or "Browsable" for this? – Artem Makarov Jun 12 '12 at 01:38

1 Answers1

0

Ok, I can't find such default attribute, so I've created my own empty attribute, call it "ShowInColumnChooserAttribute".

Mark all properties, that I don't need on dataGrid, but need on ColumnChooser with this attribute

And in dataGrid's event "ColumnsPopulated" do the next:

        var hiddenList = new List<string>();
        var r = dataTable.ItemsSource.GetType().GetGenericArguments()[0];
        foreach (var prop in r.GetProperties())
            if (prop.GetCustomAttributes(typeof(ShowInColumnChooserAttribute), true).Length > 0)
                hiddenList.Add(prop.Name);
        foreach (var column in ((DevExpress.Xpf.Grid.GridControl)sender).Columns)
                column.Visible = !hiddenList.Contains(column.FieldName);

I think that this is very easy and beautiful solution! Hope this'll help!

Artem Makarov
  • 874
  • 3
  • 14
  • 25