Welcome to the Xceed Community | Help
Community Search  
More Search Options

How to remove the default Group table header and the message

Sort Posts: Previous Next
  •  07-12-2011, 9:26 AM Post no. 30704

    How to remove the default Group table header and the message

    i was using datagrid for WPF, and generate the datagrid and add to StackPanel in window dynamiclly,

    and i do not have a xaml side code of the control,

     my code was like :

     DataGridControl dataGrid = new DataGridControl();
                    dataGrid.AutoCreateColumns = false;
                    dataGrid.ReadOnly = true;
                    dataGrid.AllowDrag = true;
                    dataTable.TableName = dataTable.TableName;
                    dataGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    dataGrid.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
                    dataGrid.Background = DataGridControlBackgroundBrushes.ElementalSilver;
                    dataGrid.Margin = new Thickness(0, 5, 0, 5);
                    dataGrid.FontFamily = new FontFamily("Arial");
                    dataGrid.FontSize = 10;

     and then set each datarow and each cell data.

    finally, i got a "Drag a column header here to group by that column" on top of the table, how can i remove this line?

     and also, how can i show a table name?

     

  •  07-12-2011, 2:11 PM Post no. 30709 in reply to 30704

    Re: How to remove the default Group table header and the message

    Hi bingqiao,

    The control at the top of the table is called the GroupByControl and you can hide that part of the DataGrid by implementing the following method:

    ----------

    public void DoHeaders()
    {
           this.dataGridControl1.View.UseDefaultHeadersFooters = false;
           this.dataGrid.View.FixedHeaders.Clear();
           DataTemplate columnHeaderTemplate = new DataTemplate();
           columnHeaderTemplate.VisualTree = new FrameworkElementFactory(typeof(ColumnManagerRow));
           TableView DataGridView = new TableView();

           DataGridView.FixedHeaders.Add(columnHeaderTemplate);
           this.dataGrid.View = DataGridView;
    }

    ----------

    The important thing is to remove the default Headers/Footers, but the issue would be that you will lose the ColumnManagerRow as well. As you can see above, we have to re-insert it into the DataGridControl.

    As for displaying the Table Name, do you mean that you wish to show the TableName of the DataTable in a header? If this is the case, I would suggest putting that information in a TextBlock on top of your DataGridControl instead. We do not support a title header within the DataGridControl.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  07-21-2011, 6:25 AM Post no. 30762 in reply to 30709

    Re: How to remove the default Group table header and the message

    Thanks very much for you reply, it works!
  •  08-18-2011, 5:18 PM Post no. 30887 in reply to 30762

    Re: How to remove the default Group table header and the message

    Hmm... That didn't work for me.
    That box that says "Drag a column header here to group by that column." is still visible.
    And now I have two rows of column headers at the top.
    I'm using version 3.7.10226.11110.
    Any ideas?

    Thanks,
    Greg

  •  08-19-2011, 2:18 PM Post no. 30889 in reply to 30887

    Re: How to remove the default Group table header and the message

    Hi Greg,

    The above code works for the most updated version of the Xceed DataGrid for WPF.  Unfortunately, we do not support older versions of the DataGrid if the code works for the updated version. If you wish to receive the updated version, you must be a valid vanguard user.

    You can download the most updated version here: http://xceed.com/pages/TopMenu/Downloads/Updates.aspx?Lang=EN-CA

    If you are not a valid vanguard user, you can contact sales by email: sales@xceed.com  or you can contact them by phone: 1-800-865-2626.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  01-25-2012, 3:45 PM Post no. 31609 in reply to 30709

    Re: How to remove the default Group table header and the message

    Where should I call this DoHeaders() method? I am getting an error when calling after InitializeComponent() method, because by this time View is null.?
  •  01-26-2012, 7:29 AM Post no. 31612 in reply to 31609

    Re: How to remove the default Group table header and the message

    Hi Mahesh,

    You should do it after the InitializeComponent() call is made. Make sure your data has been loaded and your DataGrid has been populated before you run this code.

    DataTemplate columnHeaderTemplate = new DataTemplate();
      columnHeaderTemplate.VisualTree = new FrameworkElementFactory( typeof( ColumnManagerRow ) );

      TableView DataGridView = new TableView();
      DataGridView.UseDefaultHeadersFooters = false;
      DataGridView.FixedHeaders.Add( columnHeaderTemplate );
      this.Grid.View = DataGridView;

     


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.