datagrid

Conditionally making readonly to WPF DataGridCell

非 Y 不嫁゛ 提交于 2020-01-13 08:01:09
问题 I have a situation that needs to conditionally make readonly to wpf datagrid cell. There is IsReadOnly property in DataGridCell. But unfortunately, that property is readonly! Is there any way to do it? ant. 回答1: You should be able to use the DataGrid.BeginningEdit event to conditionally check if the cell is editable and then set the Cancel property on the event args if not. 回答2: The similar solution as Goblin above, but with a little code samples: The idea is to dynamically switch the

Spark datagrid with checkbox does not update correctly

孤街醉人 提交于 2020-01-13 07:19:27
问题 The checkboxes are updated correctly when I select one or more datagrid rows but when I select a checkbox for the first time the checkbox does not refresh until the pointer moves out of the datagrid row. How can I fix this? <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <s:DataGrid id="dg" x="344" y="48" selectionMode="multipleRows" requestedRowCount="4"> <s

Display “Display name” instead of field name in WPF DataGrid

南楼画角 提交于 2020-01-13 05:08:32
问题 This is my Class definition. public class Customer { [Display(Name="Customer ID")] public int ID { get; set; } [Display(Name="Customer Name")] public string CusName { get; set; } } This is my XAML code <DataGrid Name="DataGrid" /> And this is data binding public Test() { InitializeComponent(); List<Customer> cus = new List<Customer>(); cus.Add(new Customer() { ID = 1, CusName = "Jackson" }); cus.Add(new Customer() { ID = 2, CusName = "Micheal" }); cus.Add(new Customer() { ID = 3, CusName =

DataGrid CurrentItem != SelectedItem after reentry with tab-button

流过昼夜 提交于 2020-01-12 19:16:29
问题 This simple WPF-DataGrid <DataGrid AutoGenerateColumns="False" Height="300" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="dgOriginal" Margin="4,12,0,0" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" IsSynchronizedWithCurrentItem="True" CanUserSortColumns="False" SelectionMode="Single" SelectionUnit="FullRow"> <DataGrid.Columns> <DataGridCheckBoxColumn x:Name="col2Checked"/> <DataGridTextColumn x:Name="col2Name"/> <DataGridTextColumn x:Name=

How to make gridview a child element of a treeview in wpf application

﹥>﹥吖頭↗ 提交于 2020-01-12 03:53:27
问题 I am trying to populate a datagrid (or gridview) as a child elment of a treeview from the database. I am able to get data from the DB in the tree, however, it doesnt seem to work for the datagrid. Here is my xaml code: <Window x:Class="AttemptUsingHirarchichalData.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:data="clr-namespace:AttemptUsingHirarchichalData" xmlns:my="http://schemas.microsoft.com/wpf

Is DataGrid a necessity in WPF?

感情迁移 提交于 2020-01-12 02:52:07
问题 I have seen a lot of discussions going on and people asking about DataGrid for WPF and complaining about Microsoft for not having one with their WPF framework till date. We know that WPF is a great UI technology and have the Concept of ItemsControl,DataTemplate, etc,etc to make great UX. Even WPF has got a more closely matching control- ListView, which can be easily templated to give better UX than a traditional Datagrid like display. And I would say a readymade DataGrid control will kill or

Combobox binding in Datatemplate

蓝咒 提交于 2020-01-11 14:18:14
问题 Hi i am actually creating a WPF DataGrid Custom Control. What is want this combobos should show the genders in the combobox and what is heppening when i am keeping the combobox outside the datatemplate its working but inside the datatemplate it is not working. Please help me ? <UserControl x:Class="Custom_DataGrid.Grid3.Grid3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org

CommitNew is not allowed for this View

好久不见. 提交于 2020-01-11 13:25:10
问题 I have a WPF datagrid, and one of the columns is a nested DataGrid: <DataGridTemplateColumn Header="Description" Width="{Binding DataContext.ColWidths[5].Width, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding oDesc}" AutoGenerateColumns="False" SelectedItem="{Binding CurrentDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

CommitNew is not allowed for this View

China☆狼群 提交于 2020-01-11 13:25:10
问题 I have a WPF datagrid, and one of the columns is a nested DataGrid: <DataGridTemplateColumn Header="Description" Width="{Binding DataContext.ColWidths[5].Width, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding oDesc}" AutoGenerateColumns="False" SelectedItem="{Binding CurrentDesc, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

how to set the cell value in dynamic datagrid in wpf using c#

落爺英雄遲暮 提交于 2020-01-11 12:55:09
问题 I got row id and column id dataGrid2.Items[row].Cells[column].Text = "text"; row = row index; column = column index; 回答1: you can simply update the value of the underlying datasource and its show in your datagrid. you dont need any index stuff 来源: https://stackoverflow.com/questions/17106708/how-to-set-the-cell-value-in-dynamic-datagrid-in-wpf-using-c-sharp