[英]WPF datagrid simple problem
I have a WPF DataGrid
with a data source of DataTable
. 我有一个带有DataTable
数据源的WPF DataGrid
。 This DataGrid
has just one column that is not ReadOnly
where the user must enter data. 此DataGrid
只有一列不是ReadOnly
,用户必须在其中输入数据。 How i can get values? 我如何获得价值观?
This is how i bind the data to the grid. 这就是我将数据绑定到网格的方式。
ConstructTable();
foreach (CheckOutData col in _CheckOutCollection)
{
decimal paidMoney = 0;
if (col.PaidMoney <= 0)
{
paidMoney = 0;
}
else
{
paidMoney = col.PaidMoney;
}
dt.Rows.Add(
col.ID.ToString(),
col.RoomType.ToString(),
col.RoomNumber.ToString(),
col.RoomPriceWithCurrency.ToString(),
col.Discount.ToString(),
col.DiscountedPriceWithCurrency.ToString(),
col.CheckIn.ToString(),
col.CheckOut.ToString(),
col.TotalDay.ToString(),
col.TotalPrice.ToString(),
col.IncFirstDay.ToString(),
paidMoney.ToString());
_CheckInsIDs.Add(col.ID);
}
dataGrid1.DataContext = ds.Tables[0];
I'm selecting data from an SQL Table int a Collection
col
. 我正在从Collection
col
的SQL表中选择数据。 As above, this Collection
is used to populate the DataTable
. 如上所述,此Collection
用于填充DataTable
。 i dont use more this _CheckOutCollection 我不使用更多这个_CheckOutCollection
您需要在datagrid列绑定中使用双向模式,如下所示:
Binding="{Binding ColName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.