Xceed DataGrid 中设置增加行的方法
2013-04-12 21:59
176 查看
废话不多说直接贴代码:
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:local="clr-namespace:Xceed.Wpf.Documentation">
<Grid.Resources>
<xcdg:DataGridCollectionViewSource x:Key="cvs_persons"
Source="{Binding Source={x:Static Application.Current},
Path=PersonList}"
CreatingNewItem="CollectionView_CreatingNewItem"
CommittingNewItem="CollectionView_CommittingNewItem"
CancelingNewItem="CollectionView_CancelingNewItem"/>
</Grid.Resources>
<xcdg:DataGridControl x:Name="PersonsGrid"
ItemsSource="{Binding Source={StaticResource cvs_persons}}">
<xcdg:DataGridControl.View>
<xcdg:TableView>
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:InsertionRow/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid>
上面Datagrid中最主要代码:
<xcdg:DataGridControl.View>
<xcdg:TableView>
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:InsertionRow/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
好了就这些,自己看吧!
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:local="clr-namespace:Xceed.Wpf.Documentation">
<Grid.Resources>
<xcdg:DataGridCollectionViewSource x:Key="cvs_persons"
Source="{Binding Source={x:Static Application.Current},
Path=PersonList}"
CreatingNewItem="CollectionView_CreatingNewItem"
CommittingNewItem="CollectionView_CommittingNewItem"
CancelingNewItem="CollectionView_CancelingNewItem"/>
</Grid.Resources>
<xcdg:DataGridControl x:Name="PersonsGrid"
ItemsSource="{Binding Source={StaticResource cvs_persons}}">
<xcdg:DataGridControl.View>
<xcdg:TableView>
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:InsertionRow/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>
</Grid>
private void C 4000 ollectionView_CreatingNewItem( object sender, DataGridCreatingNewItemEventArgs e ) { e.NewItem = new Person( Person.AutoIncrementID, string.Empty, string.Empty, -1 ); e.Handled = true; } private void CollectionView_CommittingNewItem( object sender, DataGridCommittingNewItemEventArgs e ) { List<Person> source = e.CollectionView.SourceCollection as List<Person>; source.Add( ( Person )e.Item ); Person.AutoIncrementID = Person.AutoIncrementID + 1; // the new item is always added at the end of the list. e.Index = source.Count - 1; e.NewCount = source.Count; e.Handled = true; } private void CollectionView_CancelingNewItem( object sender, DataGridItemHandledEventArgs e ) { // Manually handling the insertion of new items requires that the CreatingNewItem, // CommitingNewItem, and CancelingNewItem events must all be handled even if nothing // is done in the event. e.Handled = true; }
上面Datagrid中最主要代码:
<xcdg:DataGridControl.View>
<xcdg:TableView>
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:InsertionRow/>
</DataTemplate>
</xcdg:TableView.FixedHeaders>
</xcdg:TableView>
</xcdg:DataGridControl.View>
好了就这些,自己看吧!
相关文章推荐
- Phpcms v9专题分类增加模板设置的方法
- 扩展AspNetPager控件,增加动态设置PageSize的方法
- cxGrid增加一栏显示checkBox的设置方法
- 在visual studio工程设置中增加宏定义的方法
- Ios开发Swift自定义UIbutton增加一个能设置高亮状态下背景颜色的方法
- destoon实现商铺管理主页设置增加新菜单的方法
- 在visual studio工程设置中增加宏定义的方法
- cxGrid增加一栏显示checkBox的设置方法
- js+jquery动态设置/增加/删除/获取元素属性的两种方法集锦对比(动态onclick属性设置+动态title设置)
- 用友U871用户增加User用户的设置方法
- destoon实现商铺管理主页设置增加新菜单的方法
- ecshop 后台增加设置选项(系统控制变量)的方法____2016年5月28日
- cxGrid增加一栏显示checkBox的设置方法
- Ecshop后台增加商店设置选项和使用方法详解
- ZTE VX10 H618B不增加设备、不拆机、不破解,开启自带路由+iTV的详细设置方法
- destoon实现商铺管理主页设置增加新菜单的方法
- 在visual studio工程设置中增加宏定义的方法
- Win7最近使用的文档怎么设置?增加最近使用的项目方法介绍
- Phpcms v9专题分类增加模板设置的方法
- Ecshop后台增加|添加商店设置选项和使用方法详解