Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
XamDataGrid Change Column Header
posted

How can I programmatically change the column header similar to this code:

grid.Columns[0].Header = "Segment";

I've tried the following:

XamDataGrid.FieldLayouts[0].FieldItems[0].Label = "test";

But it doesn't work because I'm setting the columns in the code behind and not the front end like so:

DataTable dtDataGrid = new DataTable();

dtDataGrid.Columns.Add("Segment", typeof(string));

XamDataGrid.DataSource = dtDataGrid.DefaultView;

  • 29065
    Offline posted

    Hello, 

    You need to set the Label property off of the instance of your control, eg "grid".

    FieldItems worked for me, but you can try using the Fields too.

    eg. 

    grid.FieldLayouts[0].Fields[0].Label = "test";

    If this doesn't work please send a sample isolating this.