datagrid

Assigning Style resources to a DataGrid

元气小坏坏 提交于 2020-01-24 07:46:26
问题 Apologies for the maybe hazy nature of this question, but I am fairly new to WPF and am consequently struggling with the issue of resources. My problem is that I have a DataGrid that I wish to assign a style to that describes properties such as the FontSize and Background / Foreground colours (when the mouse hovers over the rows). I can do this successfully as follows: <Window x:Class="WpfApplication11.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http

Assigning Style resources to a DataGrid

徘徊边缘 提交于 2020-01-24 07:46:19
问题 Apologies for the maybe hazy nature of this question, but I am fairly new to WPF and am consequently struggling with the issue of resources. My problem is that I have a DataGrid that I wish to assign a style to that describes properties such as the FontSize and Background / Foreground colours (when the mouse hovers over the rows). I can do this successfully as follows: <Window x:Class="WpfApplication11.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http

BeginEdit of a specific Cell from code behind

ぐ巨炮叔叔 提交于 2020-01-23 18:56:05
问题 Is possibile begin edit of a specific cell from code behind with DataGrid control (WPF Toolkit)? I have to enable the celledittemplate of first cell of selected row after a button action...how can I do? 回答1: pls, try putting the code below in your button's on click event handler: DataGridCell cell = GetCell(1, 0); if (cell != null) { cell.Focus(); yourDataGrid.BeginEdit(); } below is implementation for the GetCell method taken from here Grabing controls from a DataGrid public DataGridCell

WPF/Dataset: How do you XAML bind data from a related table into a datagrid column?

守給你的承諾、 提交于 2020-01-23 15:53:54
问题 I am working with WPF, DataSet (connection is to SQL Server Express), XAML and C#. Visual Studio 2013 Express. I have created a DataSet called BankNoteBookDataSet from an existing SQL Server Express database named BankNoteBook. In the SQL database there is a table named Catalogue, and to keep it simple here, it has 2 fields: BNBID and CountryID. BNBID is the unique ID and Country ID field has a many to one relationship with another table named Country. The Country table has 2 fields:

WPF/Dataset: How do you XAML bind data from a related table into a datagrid column?

人盡茶涼 提交于 2020-01-23 15:53:45
问题 I am working with WPF, DataSet (connection is to SQL Server Express), XAML and C#. Visual Studio 2013 Express. I have created a DataSet called BankNoteBookDataSet from an existing SQL Server Express database named BankNoteBook. In the SQL database there is a table named Catalogue, and to keep it simple here, it has 2 fields: BNBID and CountryID. BNBID is the unique ID and Country ID field has a many to one relationship with another table named Country. The Country table has 2 fields:

Binding matrix arrays to WPF DataGrid

浪子不回头ぞ 提交于 2020-01-23 13:29:47
问题 I have 3 string arrays like this: public string[] RowHeaders { get { return new[] {"RowHeader1", "RowHeader2", "RowHeader3", "RowHeader4"}; } public string[] ColumnHeaders { get { return new[] {"ColumnHeader1", "ColumnHeader2", "ColumnHeader3"}; } } public string[][] Values { get { return new[] { new []{"Value11", "Value12", "Value13"}, new []{"Value21", "Value22", "Value23"}, new []{"Value31", "Value32", "Value33"}, new []{"Value41", "Value42", "Value43"}, }; } } Array sizes are unknown

Binding matrix arrays to WPF DataGrid

笑着哭i 提交于 2020-01-23 13:29:19
问题 I have 3 string arrays like this: public string[] RowHeaders { get { return new[] {"RowHeader1", "RowHeader2", "RowHeader3", "RowHeader4"}; } public string[] ColumnHeaders { get { return new[] {"ColumnHeader1", "ColumnHeader2", "ColumnHeader3"}; } } public string[][] Values { get { return new[] { new []{"Value11", "Value12", "Value13"}, new []{"Value21", "Value22", "Value23"}, new []{"Value31", "Value32", "Value33"}, new []{"Value41", "Value42", "Value43"}, }; } } Array sizes are unknown

How I can Delete Selected Row in datagrid wpf?

我怕爱的太早我们不能终老 提交于 2020-01-23 06:53:42
问题 I am using WPF datagrid I need to delete selected Row , my code is private void dataGridView1_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { this.dataGridView1.Items.Remove(this.dataGridView1.SelectedItem); } } But when I using this code show me error Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead How I can Delete Selected Row ? 回答1: You never have to delete the row from the WPF grid. What you

How to programmatically add rows to DataGrid in C#?

喜你入骨 提交于 2020-01-23 06:00:05
问题 So as the title states, I'm trying to add rows to a DataGrid programmatically using C# but I can't seem to make it work. This is what I have so far. // I have a DataGrid declared as dg in the XAML foreach (string s in array) { int index = 0; DataGridRow dgRow = new DataGridRow(); foreach (DataGridColumn dgColumn in columns) { // Trying to add Text to dgRow here but IDK how index++; } } I've been googling around and the closest I got to adding anything was to use {column = value} but it just

DataGrid SelectionUnit=Cell disables all support for a selected row?

时光毁灭记忆、已成空白 提交于 2020-01-22 17:48:06
问题 .Net 4 WPF DataGrid C# MMVM When the DataGrid SelectionUnit is full row, wpf databinding and the collectionview take care of letting me know in the viewmodel what is the actively selected item via the view's currentitem property. This works great for readonly grids with the selection mode set to the fullrow. Now I have an editable grid. So I set the SelectionUnit=Cell to make it easier to spot which cell one is in. Now all of a sudden the grid no longer has any ability to track the selection