如何在WPF中通过c#将单元格值添加到gridcontrol [英] How to add cell values to the gridcontrol via c# in WPF

查看:528
本文介绍了如何在WPF中通过c#将单元格值添加到gridcontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DevExpress网格控件,grdcntrl在xaml中有10个固定字段(列)

项目源是使用按钮点击事件中的c#代码给出的grdcntrl,可观察集合,它有超过10个字段

工作正常并显示10列,模板中给出模板。

现在我动态地将一些字段(列)添加到grdcntrl,如下面的代码: br />

I have a DevExpress grid control, grdcntrl with 10 fixed fields(columns) in xaml
items source is given for grdcntrl using c# code in a button click event, the observable collection, which is having more than 10 fields
its working fine and showing 10 columns with templates given in xaml.
Now i added some fields(columns) to the grdcntrl dynamically like following codes:

GridColumn column = new GridColumn() 
{ 
Name = "columnName", FieldName = "columnName", Header = "description", Width = 150 
};
grdcntrl.Columns.Add(column);



工作......

但是我想设置一些值像


Worked...
But While i am trying to set some value to the cells like

List<int> lst = GridRowHandle.GetDataRowHandles(grdcntrl);
string cellvalue = "";
foreach (int rwHandle in lst)
{
cellvalue = "something1";
grdcntrl.SetCellValue(rwHandle, "columnName", cellvalue);
}



它没有将单元格值添加到grdcntrl ..它显示xaml中的10个固定列的值,并添加了带有空单元格的列。

如何在新添加的列下为单元格添加单元格值?


its not adding the cell values to the grdcntrl..Its showing the values for 10 fixed columns mensioned in xaml and added columns with empty cells.
How to add cell values to the cells under newly added columns??

推荐答案

我得到了解决方案,通过设置值来处理问题在CustomUnboundColumnData事件..
I got the solution, handled the issue by setting the values in "CustomUnboundColumnData" event..


这篇关于如何在WPF中通过c#将单元格值添加到gridcontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆