如何在datagrid c#的第一列中添加tickbox [英] how to add tickbox in the first column in the datagrid c#

查看:60
本文介绍了如何在datagrid c#的第一列中添加tickbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有



我正在进行Windows移动开发。我目前有一个数据网格,我想在第一列添加另一列是tickbox。所以我可以勾选以选择我想要选择的行,因为datagrid将返回许多行。换句话说,从Web服务返回的数据行可以清楚地显示哪些行是我想要的行。



非常感谢提前

解决方案

我对Windows移动开发一无所知。

但我昨天在wpf做了同样的事情。也许你可以使用它或者说它并且我会清理它。

 <   DataGrid         IsEnabled   =  True    CanUserResizeRows   =  False    CanUserDeleteRows   =  False   高度  =  200    x:名称  =  Games_Grid    MaxHeight   =  400    ItemsSource   =  {Binding GameOverview}      FontSize   =  16    SelectedItem   =  {Binding SelectedGameOverview}    ScrollViewer.Horizo​​ntalScrollBarVisibility   = 自动    ScrollViewer.VerticalScrollBarVisibility   = 自动      mvvm:SelectedItemsBehavior.SelectedItemsChangedHandler   =  {Binding Path = ResultsSelectionChangedCommand} >  
< span class =code-keyword>< DataGrid.RowHeaderTemplate >
< DataTemplate >
< 网格 >
< CheckBox IsChecked = {Binding Path = IsSelected,Mode = TwoWay,RelativeSource = {RelativeSource FindAncestor,AncestorType = {x:Type DataGridRow}}} / >
< / Grid >
< / DataTemplate >
< < span class =code-leadattribute> / DataGrid.RowHeaderTemplate >
< / DataGrid >







我来自的SelectedItemBehavior:

http://stackoverflow.com/questions/1579700/wpf-toolkit-datagrid-multi-select-how-to-get-selecteditems-out [<一个href =http://stackoverflow.com/questions/1579700/wpf-toolkit-datagrid-multi-select-how-to-get-selecteditems-outtarget =_ blanktitle =New Window> ^


hi,all

i an doing an windows mobile development. i currently got a datagrid and i want to add another column which is tickbox in the first column. so that i can tick to choose which row i want to select since the datagrid will return many rows. In another word, the data rows returned from the webservice can be clearly shows which rows are the ones i want.

many thanks in advance

解决方案

I know nothing about windows mobile development.
But I did the same in wpf yesterday. Maybe you can use it or otherwise say it and I will clean it.

<DataGrid   IsEnabled="True" CanUserResizeRows="False" CanUserDeleteRows="False" Height="200" x:Name="Games_Grid" MaxHeight="400" ItemsSource="{Binding GameOverview}"  FontSize="16" SelectedItem="{Binding SelectedGameOverview}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"  mvvm:SelectedItemsBehavior.SelectedItemsChangedHandler="{Binding Path=ResultsSelectionChangedCommand}">
            <DataGrid.RowHeaderTemplate>
                <DataTemplate>
                    <Grid>
                        <CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor,  AncestorType={x:Type DataGridRow}}}"/>
                    </Grid>
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>
       </DataGrid>




The SelectedItemBehavior I have from:
http://stackoverflow.com/questions/1579700/wpf-toolkit-datagrid-multi-select-how-to-get-selecteditems-out[^]


这篇关于如何在datagrid c#的第一列中添加tickbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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