我需要在同一列中渲染具有不同类型的单元格的数据杂交.例如,我有一个带有"名称"和列"值"列的datagrid.根据记录的"类型",我将在"值"或简单的文本字段中具有不同的单元格"值".而且我真的看不到如何以编程方式进行此操作...我不知道数据杂志是否是最佳选择.有提示吗? 我正在使用asp.net/vb.net与框架3.5 解决方案 您可以使用用户控件来执行此操作,然后将"类型"传递给用户控件,并且用户控件将处理显示或生成的控件类型.
以下是关于 datagridtemplatecolumn 的编程技术问答
我有一个形式,它具有网格. 我自动化列并根据需要调整它们: if (e.PropertyName == "id") { System.Windows.Style style = new Style(typeof(DataGridCell)); style.Setters.Add(new Setter(DataGridCell.ContentTemplateProperty, CreateBtnTemplate(30))); e.Column.CellStyle = style; } private static DataTemplate CreateBtnTemplate(int width) { string str = ""
我试图将数据杂志中的列的可见性绑定到ViewModel中的boolean depentencyProperty(在这种情况下为视图的数据上下文设置为数据上下文). 由于某种原因(我似乎不明白)这只是不起作用. 在这里查看之后,我发现DataGridTemplate(和任何其他模板)不是视觉树的一部分.所以我无法绑定. 对问题的任何简单解决方案(当然不破坏MVVM模式)? 解决方案 在这里找到解决方案: http://www.thomaslevesque.com/2011/03/21/wpf-how-to-bind-to-bind-to-data-when-the-datacontext-is-not-inherited/ 对于将来的quenstions ...
我想在表单元格中添加一个组合框以提供拖放n滴选项lwuit. 我已经使用了此选项. private String strCmbBox[] = { "1", "2", "3", "4" }; ComboBox comboRdoBox = new ComboBox(strCmbBox); comboRdoBox.setListCellRenderer(new comboBoxRenderer()); TableModel model = new DefaultTableModel(new String[] { "Col 1", "Col 2", "Col 3" }, new Object[][] { {"Row 1",new DefaultTableModel(new String[] { "1" }, new Object[][] { { comboRdoBox }, {
我正在使用以下WPF DataGrid+Combobox方案. 我有一组看起来像; 的类 class Owner { int ID { get; } string Name { get; } public override ToString() { return this.Name; } } class House { int ID { get; } Owner HouseOwner { get; set; } } class ViewModel { ObservableCollection Owners; ObservableCollection Houses } 现在我的期望结果是一个数据杂志,显示了类型 house 的行列表,在其中一列中,是一个combobox,它允许用户更改 house的值房屋所有者. 在这种情况下,网格的dataCon
我正在使用WPF工具包的WPF DataGrid. 我在我的DataGrid中添加了一个模板列,每个单元格中都有CheckBox.现在如何访问这些单元格中的值? DataGrid中的其他列来自DataSet.我可以访问这些,但是我无法获得DataGridTemplateColumn的值,我添加到DataGrid. 有人有任何想法吗? 解决方案 现在您将东西从视觉树中拉出.那就是艰苦的工作,您找不到绑定,因为它埋在单元格模板中.我所做的是为这种东西添加自己的列,该列源自datagridboundcolumn,这意味着它像其他所有内容一样具有绑定:(我一段时间以前写了它,它可能与某些人一起看).我只是使用直接绑定.我不必设置单元格模板,我只能使用我更喜欢的datatemplate. public class DataGridReadOnlyObjectDisplayColumn : DataGridBoundColumn { public
我正在尝试获取与特定DataGridColumn相关联的属性的名称,以便我可以基于此做一些事情.当用户单击列的标题上的上下文菜单项时,此功能是调用的... 这对于开箱即用的现成的列类型(例如DataGridTextColumn)来说是可以的,因为它们是绑定的,但问题是我的某些列是DataGridTemplateColumns,它们不绑定. private void GroupByField_Click (object sender, RoutedEventArgs e){ MenuItem mi = (MenuItem)sender; ContextMenu cm = (ContextMenu) mi.Parent; DataGridColumnHeader dgch = (DataGridColumnHeader) cm.PlacementTarget; DataGridBoundColumn dgbc = (