【发布时间】:2014-03-21 20:20:44
【问题描述】:
我想将我必须的 p&l 列设置为货币,当我绑定它时效果很好,很容易在 XAML 中设置,但我有不使用绑定的内部数据网格,所以我需要将其格式更改为货币在后面的代码中。我该怎么做,这是我目前所拥有的:
private void dataGrid_RowDetailsVisibilityChanged(object sender, ExtendedGrid.Microsoft.Windows.Controls.DataGridRowDetailsEventArgs e)
{
//Get TradeID to query inner table by that trade id
var row = e.Row;
var drv = (DataRowView)row.DataContext;
int TradeID = drv.Row.Field<int>(ColTradeID);
ExtendedGrid.Microsoft.Windows.Controls.DataGrid innerDataGrid = e.DetailsElement as ExtendedGrid.Microsoft.Windows.Controls.DataGrid;
DataTable TableView = null;
//check if tradeid selected already exists
if (selectedRowView.ContainsKey(TradeID))
{
TableView = selectedRowView[TradeID]; //selectedrowview is a dictionary of datatables that stores what to load in itemsource based on a tradeId
innerDataGrid.ItemsSource = ((IListSource)selectedRowView[TradeID]).GetList();
//Format Columns
innerDataGrid.Columns[10].CellStyle = "C"; // **I want currency, this doesn't work,
//I also tried typing defaultcelltype.format and nothing would come up its not available for use**
}
}
另外,我使用的是 WPF 扩展数据网格,而不是 WPF 内置的。
【问题讨论】: