datagrid

Adding a small, coloured rectangle in DataGrid cell

人盡茶涼 提交于 2021-02-08 13:25:17
问题 I am looking to add a tiny (10x10) rectangle as a cell in my DataGrid. I already have it set in the object I'm just looking for a way to get it from the code into my DataGrid. This is my DataGrid XAML: <DataGrid Name="dataGrid1" Grid.Row="2" AutoGenerateColumns="False" DataContext="{Binding}" HeadersVisibility="Column" HorizontalGridLinesBrush="#ccc" VerticalGridLinesBrush="#ccc" VirtualizingStackPanel.VirtualizationMode="Standard" Background="#FFF6F6F6" CanUserAddRows="False"> <DataGrid

EF Core - Disposable DbContext and Attach() - or - DbContext as member - or - Disconnected Entities

时光总嘲笑我的痴心妄想 提交于 2021-02-08 06:43:28
问题 I'm not sure about how to correctly use the DbContext for Entities bound to a WPF DataGrid? How do I correctly "re-attach" and save changes to the database for all the entities that were loaded to the datagrid during UserControl load? I was using a DbContext as a member variable and ObservableCollection as DataSource for Datagrids. So everything was fine so far, no need to search for errors in the code below. Just to show what I have done so far. // Old code - working perfectly as desired

How to reuse a custom datagrid column code in WPF?

為{幸葍}努か 提交于 2021-02-08 05:43:20
问题 Using VS 2010 I plan to make several datagrid template columns, but they will all contain a textblock and I want to them to behave like a text column in terms of sorting, filtering, editing, etc. (For example, a column that has a textblock and an image within a stackpanel, but behavior-wise it should really be all about the text.) When using a template column, I've learned that much of the functionality associated with a normal text cell must be redone. For instance, in order to make the text

WPF DataGrid: How do I access a ComboBox in a specific row of a DataGridTemplateColumn?

℡╲_俬逩灬. 提交于 2021-02-08 03:42:25
问题 My app correctly populates a DataGrid column with ComboBoxes, using the following XAML code: <DataGridTemplateColumn Header="Thickness"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding SteelThickness, RelativeSource={RelativeSource AncestorType=Window}}" SelectedItem="{Binding BottomPlateThickness, UpdateSourceTrigger=PropertyChanged}" SelectionChanged="ComboBox_SelectionChanged" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <

How to search in Data gridview in C# Windows Form application?

和自甴很熟 提交于 2021-02-07 08:28:00
问题 I have a form in which a simple gridview is populated by a table in database having columns like TicketID, Name, Company, Product etc. Now I want to add a search feature so that user could search by customer name or company or TicketID. How can I do that ? I want to place a combox box, textbox and a simple "search" button above datagrid. When the user selects TicketID for example, enters "1" in textbox and presses "Search", it should refresh datagrid with entry where TicketID = 1. Now I don't

How to search in Data gridview in C# Windows Form application?

你离开我真会死。 提交于 2021-02-07 08:22:14
问题 I have a form in which a simple gridview is populated by a table in database having columns like TicketID, Name, Company, Product etc. Now I want to add a search feature so that user could search by customer name or company or TicketID. How can I do that ? I want to place a combox box, textbox and a simple "search" button above datagrid. When the user selects TicketID for example, enters "1" in textbox and presses "Search", it should refresh datagrid with entry where TicketID = 1. Now I don't

How to make one column editable in a readonly datagrid?

只愿长相守 提交于 2021-02-06 10:46:20
问题 How to make one column editable in a readonly datagrid? <DataGrid x:Name="dgLoadDtl" Height="315" Width="710" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Style="{DynamicResource StyleDatagrid}" IsReadOnly="true"> <DataGrid.Columns> <DataGridTextColumn Foreground="Black" Width="60" Header="Sctn" Binding="{Binding Sctn, Mode=TwoWay}" IsReadOnly="false" /> <DataGridTextColumn Foreground="Black" Width="140" Header="CustName" Binding="{Binding CustName, Mode=TwoWay}" />

How to make one column editable in a readonly datagrid?

十年热恋 提交于 2021-02-06 10:46:12
问题 How to make one column editable in a readonly datagrid? <DataGrid x:Name="dgLoadDtl" Height="315" Width="710" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Bottom" Style="{DynamicResource StyleDatagrid}" IsReadOnly="true"> <DataGrid.Columns> <DataGridTextColumn Foreground="Black" Width="60" Header="Sctn" Binding="{Binding Sctn, Mode=TwoWay}" IsReadOnly="false" /> <DataGridTextColumn Foreground="Black" Width="140" Header="CustName" Binding="{Binding CustName, Mode=TwoWay}" />

Getting selected Item in DataGrid in WPF

与世无争的帅哥 提交于 2021-02-05 08:33:26
问题 I have a datagrid and textboxes. When I select a row in DataGrid I want the textboxes to be filled with related data of that datagrid column. Here is the picture., I have written this code in MainWindow.xaml.cs : private void personelEntityDataGrid_Loaded(object sender, RoutedEventArgs e) { PersonelEntity pers = (PersonelEntity)personelEntityDataGrid.SelectedItem; NameBox.Text = pers.Name; // I get exception here AgeBox.Text = pers.Age.ToString(); PhoneNumberBox.Text = pers.PhoneNumber;

MVVM WPF ComboBox SelectedItem Binding not activated inside datagrid

穿精又带淫゛_ 提交于 2021-02-04 14:49:26
问题 I have struggled to save my combobox selected value when operating inside a datagrid. When I make a test solution with no datagrid things are working ok. The context are person names with associated countries. The countries are stored in a xml file. Here is a snapshot of the initial view: You see here the (important parts of the)PersonList.xaml: <UserControl.Resources> <XmlDataProvider x:Key="Dataxml" Source="\Properties\AllCountries.xml" /> <model:Person x:Key="Person"/> </UserControl