找回密码
 立即注册

QQ登录

只需一步,快速开始

xuanyuan

银牌会员

8

主题

16

帖子

3722

积分

银牌会员

积分
3722

活字格认证

xuanyuan
银牌会员   /  发表于:2012-8-7 10:13  /   查看:9163  /  回复:7
下拉列表添加后,还要保证包含下拉框的cell还要内容可编辑

7 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-8-7 16:53:00
沙发
xuanyuan 你好

你可以将C1FlexGrid列的模板设置为ComboBox,这样就可以在C1FlexGrid中使用ComboBox。
回复 使用道具 举报
xuanyuan
银牌会员   /  发表于:2012-8-9 12:16:00
板凳
回复 2楼dof的帖子

C1FlexGrid列的模板设置为ComboBox,是怎么设置的?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-8-9 18:06:00
地板
xuanyuan 你好

我这边正在做这样的Demo,明天上可以发送给你。
回复 使用道具 举报
xuanyuan
银牌会员   /  发表于:2012-8-10 14:41:00
5#
回复 4楼dof的帖子

求Demo
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-8-10 15:51:00
6#
请参考下面的代码片段:
  1.         <c1:C1FlexGrid Name="_flex" Grid.Row="1" AutoGenerateColumns="False">
  2.             <c1:C1FlexGrid.Columns>

  3.                 <!-- add some bound columns as usual -->
  4.                 <c1:Column Header="Line" Binding="{Binding Line}" />
  5.                 <c1:Column Header="Name" Binding="{Binding Name}" />
  6.                 <c1:Column Header="Color" Binding="{Binding Color}" />
  7.                 <c1:Column Header="Price" Binding="{Binding Price, StringFormat=c}" HorizontalAlignment="Right" />
  8.                 <c1:Column Header="Rating" >
  9.                     <c1:Column.CellTemplate>
  10.                         <DataTemplate>
  11.                             <ComboBox SelectedIndex="{Binding Rating}">
  12.                                 <ComboBoxItem Content="0" />
  13.                                 <ComboBoxItem Content="1" />
  14.                                 <ComboBoxItem Content="2" />
  15.                                 <ComboBoxItem Content="3" />
  16.                                 <ComboBoxItem Content="4" />
  17.                             </ComboBox>
  18.                         </DataTemplate>
  19.                     </c1:Column.CellTemplate>
  20.                 </c1:Column>
  21.             </c1:C1FlexGrid.Columns>
  22.         </c1:C1FlexGrid>
复制代码
回复 使用道具 举报
xuanyuan
银牌会员   /  发表于:2012-8-13 11:16:00
7#
回复 6楼dof的帖子

这样下拉菜单中的内容已经写死了,我需要与DB中的内容对应,而DB中是可变的
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-8-14 15:15:00
8#
回复 7楼xuanyuan的帖子

回复 7楼xuanyuan的帖子

如果ComboBox的数据是动态的,可以使用下面的方法来实现

XAML:
  1.         <c1:C1FlexGrid Name="_flex" Grid.Row="1" AutoGenerateColumns="False">
  2.             <c1:C1FlexGrid.Columns>

  3.                 <!-- add some bound columns as usual -->
  4.                 <c1:Column Header="Line" Binding="{Binding Line, Mode=TwoWay}" />
  5.                 <c1:Column Header="Name" Binding="{Binding Name, Mode=TwoWay}" />
  6.                 <c1:Column Header="Color" Binding="{Binding Color, Mode=TwoWay}" />
  7.                 <c1:Column Header="Price" Binding="{Binding Price, StringFormat=c, Mode=TwoWay}" HorizontalAlignment="Right" />
  8.                 <c1:Column Header="Rating" Binding="{Binding Rating, Mode=TwoWay}"/>
  9.             </c1:C1FlexGrid.Columns>
  10.         </c1:C1FlexGrid>
复制代码


MainPage.xaml.cs:
  1.     public partial class MainPage : UserControl
  2.     {
  3.         // data source
  4.         System.ComponentModel.ICollectionView _view = Product.GetProducts(200);

  5.         public MainPage()
  6.         {
  7.             InitializeComponent();            
  8.             
  9.             // bind the grid to the data
  10.             _flex.ItemsSource = _view;

  11.             _flex.PrepareCellForEdit += new EventHandler<CellEditEventArgs>(_flex_PrepareCellForEdit);
  12.         }

  13.         void _flex_PrepareCellForEdit(object sender, CellEditEventArgs e)
  14.         {
  15.             if (_flex.Columns[e.Column].BoundPropertyName == "Rating")
  16.             {
  17.                 var combo = (e.Editor as Border).Child as C1FlexComboBox;
  18.                 combo.DropDownItems = new int[] { 0, 1, 2, 3, 4, 5, 6 };
  19.             }
  20.         }
  21.     }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部