在开始时,我想标记一下我正在.NET v 3.5 for MobileCE上对此进行编程。
我的第一个问题是我无法在DataGrid中隐藏列。我在TableStyles必需属性中的DataGrid上进行设置。在编辑器中,我可以看到此更改,因为我只能看到在TableStyles中定义的该列,但是当我在设备上发送该列时,将显示所有列。
Here in MappingName I set name of class that contains definition of loading data.
这是我的数据定义:
class Trasnd
{
public string REF { get; set; }
public string NR { get; set; }
public string SYM { get; set; }
public string DATE { get; set; }
internal static List<Trasnd> getDataWs()
{
......
}
}
接下来,我使用此代码将数据加载到DataGrid(核心加载)
dataGrid1.DataSource = Trasnd.getDataWs();
尝试隐藏代码中的列也不起作用。我不知道该怎么做。
第二个问题是当我在属性中更改MappingName并想要保存项目时:
Code generation for property 'FormatInfo' failed. Error was: 'Object
reference not set to an instance of an object.
我应该使用类的名称(具有数据定义)还是使用其他名称,而我在做什么错呢?
答案 0 :(得分:0)
如果要隐藏列,请使用此代码
int Column_Index = 2;
dataGrid1.Columns[Column_Index].Visible = false;
答案 1 :(得分:0)
通过背后的代码,您可以这样做
if(grdEmployee.Columns.Count> 0) grdEmployee.Columns [0] .Visible = false;
使用CSS:
.hideGridColumn { 显示:无; }