本帖最后由 medicside 于 2020-8-12 13:21 编辑
c1:C1FlexGrid 绑定 AsyncObservableCollection<T> 集合,
<c1:C1FlexGrid Name="flexGrid" Grid.Column="0" Margin="0,10,0,0" SelectionMode="RowRange" AutoGenerateColumns="False"
VerticalScrollBarVisibility="Visible"
SelectedItemChanged="FlexGrid_SelectedItemChanged" MouseDoubleClick="flexGrid_MouseDoubleClick"/>
绑定代码
flexGrid.ItemsSource = PlantForm.Current.SampleList;
在集合添加新元素
PlantForm.Current.SampleList.Insert(0,sample);
调用,下面函数,设置编号
private void SetFlexGridHeadeNo()
{
for (int i = 0; i < flexGrid.Rows.Count; i++)
{
flexGrid.RowHeaders[i, 0] = i + 1;
}
}
编号会错误,如图
调试发现第一次加入元素PlantForm.Current.SampleList.Insert(0,sample),后flexGrid.Rows.Count是0,出现了这问题
|