Hi, I have a telerik rad gridview that auto-generates columns. I want to change formats, fonts and text alignments for specific columns. Right now I have the following code:
I've noticed a few things - it cant edit columns that is the current column or it wont display, hence I manually add a extra column called "dummy" then edit the columns that are already generated.
Also, and this is my main concern, text alignment doesn't seem to be working .. the code runs by the text alinement for that column is still left justified.
Can you provide a sample code that changes the text alignment for a single column?
thanks
private void CustomerDataGrid_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
{
if (e.Column.Header.ToString() == "dummy")//WSS
{
((GridViewDataColumn)this.CustomerDataGrid.Columns["trade_Date"]).DataFormatString = "{0:d}";
((GridViewDataColumn)this.CustomerDataGrid.Columns["value_Date"]).DataFormatString = "{0:d}";
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Bought"]).DataFormatString = "{0:N2}";
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Sold"]).DataFormatString = "{0:N2}";
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Bought"]).TextAlignment = TextAlignment.Right;
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Sold"]).TextAlignment = TextAlignment.Right;
((GridViewDataColumn)this.CustomerDataGrid.Columns["deal_Number"]).Header = "Deal Number";
((GridViewDataColumn)this.CustomerDataGrid.Columns["trade_Date"]).Header = "Trade Date";
((GridViewDataColumn)this.CustomerDataGrid.Columns["value_Date"]).Header = "Value Date";
((GridViewDataColumn)this.CustomerDataGrid.Columns["tran_Type"]).Header = "Tran Type";
((GridViewDataColumn)this.CustomerDataGrid.Columns["cross"]).Header = "Cross";
((GridViewDataColumn)this.CustomerDataGrid.Columns["CCY_Bought"]).Header = "CCY Bought";
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Bought"]).Header = "Amt Bought";
((GridViewDataColumn)this.CustomerDataGrid.Columns["CCY_Sold"]).Header = "CCY Sold";
((GridViewDataColumn)this.CustomerDataGrid.Columns["amt_Sold"]).Header = "Amt Sold";
((GridViewDataColumn)this.CustomerDataGrid.Columns["CCY_Bought"]).Header = "CCY Bought";
e.Column.IsVisible = false;
}
}
I've noticed a few things - it cant edit columns that is the current column or it wont display, hence I manually add a extra column called "dummy" then edit the columns that are already generated.
Also, and this is my main concern, text alignment doesn't seem to be working .. the code runs by the text alinement for that column is still left justified.
Can you provide a sample code that changes the text alignment for a single column?
thanks