c1:C1DataGrid 绑定DataTable后卡死(界面动不了),但是不报错问题。
在绑定完数据后就卡死了,界面就点击不动了?是我哪写的有问题吗?CS 后台代码,点击按钮后触发,查询数据进行绑定
TestDal dal = new TestDal();
DataTable dt = dal.GetCheck_RecordsetMain_Pad(tb_Serno.Text, tb_PersonID.Text,(DateTime) StartDate.DateTime, (DateTime)EndDate.DateTime);
MyGrid.ItemsSource = dt.DefaultView;
前台代码,
<c1:C1DataGrid x:Name="MyGrid" AutoGenerateColumns="False"HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
CanUserFreezeColumns="None"
IsReadOnly="True"
GridLinesVisibility="All">
<!--<c1:C1RowIndexHeaderBehavior.RowIndexHeaderBehavior>
<c1:C1RowIndexHeaderBehavior InitialIndex="1"/>
</c1:C1RowIndexHeaderBehavior.RowIndexHeaderBehavior>-->
<c1:C1DataGrid.Columns>
<c1:DataGridTextColumn Binding="{Binding Path=ID}" Width="60"FilterMemberPath="ID" SortMemberPath="ID" Header="ID" />
<c1:DataGridTextColumn Binding="{Binding OrderNo}" Width="77"FilterMemberPath="订单号" SortMemberPath="订单号" Header="订单号"/>
<c1:DataGridTextColumn Binding="{Binding ProdID}" Width="120"FilterMemberPath="物料编码" SortMemberPath="物料编码" Header="物料编码"/>
<c1:DataGridTextColumn Binding="{Binding SlbNo}" Width="100"FilterMemberPath="SlbNo" SortMemberPath="SlbNo" Header="SlbNo"/>
<c1:DataGridTextColumn Binding="{Binding OperaterType_Name}" Width="80"FilterMemberPath="检验类型" SortMemberPath="检验类型" Header="检验类型"/>
<c1:DataGridTextColumn Binding="{Binding Frequency_Name}" Width="77"FilterMemberPath="检验过程" SortMemberPath="检验过程" Header="检验过程"/>
<c1:DataGridTextColumn Binding="{Binding SemiProduct_SerNo}" Width="90"FilterMemberPath="订单唯一码" SortMemberPath="订单唯一码" Header="订单唯一码"/>
<c1:DataGridTextColumn Binding="{Binding prdPerson}" Width="70"FilterMemberPath="工号" SortMemberPath="工号" Header="工号"/>
<c1:DataGridTextColumn Binding="{Binding PersonName}" Width="100"FilterMemberPath="检验人" SortMemberPath="检验人" Header="检验人"/>
<c1:DataGridTextColumn Binding="{Binding Note}" Width="100"FilterMemberPath="备注" SortMemberPath="备注" Header="备注"/>
<c1:DataGridTextColumn Binding="{Binding Recorddate}" Width="100"FilterMemberPath="检验时间" SortMemberPath="检验时间" Header="检验时间"/>
<c1:DataGridTextColumn Binding="{Binding ProcessName}" Width="100"FilterMemberPath="工序" SortMemberPath="工序" Header="工序"/>
<c1:DataGridTextColumn Binding="{Binding ObjectID}" Width="100"FilterMemberPath="料号" SortMemberPath="料号" Header="料号"/>
</c1:C1DataGrid.Columns>
</c1:C1DataGrid> 回复 1楼llsyz02的帖子
谢谢您的反馈。
测试简单的DataTable作为数据源,不能重现您的问题。
代码参考:
Public Sub FillC1Grid(ByVal PassedTable As DataTable, ByVal PassedGrid As C1DataGrid)
C1DataGrid1.ItemsSource = PassedTable.DefaultView
' Note: AutoPopulateColumns must be set to false.
For Each dc In PassedTable.Columns
Dim col As New DataGridTextColumn ' You must explicitly define the column type.
col.Binding = New Binding(dc.ColumnName)
col.Binding.Mode = BindingMode.TwoWay
col.SortMemberPath = dc.ColumnName
col.FilterMemberPath = dc.ColumnName
col.Header = dc.ColumnName
PassedGrid.Columns.Add(col)
Next
End Sub
建议您绑定一个数据少的DataTable,测试是不是数据源的问题(数据量过大,或是数据源数据有问题)? 回复 2楼Alice的帖子
确实是因为数据过多,一半都是显示多少数据? 回复 2楼Alice的帖子
我查的结果集有5000多点数据,就卡住了出不来。 回复 1楼llsyz02的帖子
我尝试绑定100多条数据就有点卡,怎么让他出滚动条,上下滚动,标题都在上面的这种。我看例子上有300多条数据,速度还成,为什么用DataTable绑定100多条就有点卡?
回复 5楼llsyz02的帖子
对于C1DataGrid,当列或行超过grid的范围,就会自动的展示滚动条。
对于性能问题和平台本身也有很大的影响,建议使用微软的DataGrid控件做对比测试。
如果为了提高滚动的性能,可以将C1DataGrid.ScrollMode属性设置为deferred,延迟滚动,可以提高性能。 回复 6楼Alice的帖子
okay,已解决。 回复 7楼llsyz02的帖子
谢谢反馈。
页:
[1]