wpfdatagrid

How to Change Cell background color in WPF Datagrid

为君一笑 提交于 2020-06-27 04:10:22
问题 I want to change the cell background color in my WPF Datagrid application when I select a cell and click on "Red Button" or "Blue Button" in UI. I'm a beginner to this WPF Datagrid architecture and really appreciate if someone can help me with this. (I'm using MVVM for my application) 回答1: Something like this: private void Form1_Click(object sender, System.EventArgs e) { this.BackColor = System.Drawing.Color.DarkBlue; } 回答2: Something like the following would allow you to change a specific

WPF get TextBox Value from datagridtemplatecolumn

有些话、适合烂在心里 提交于 2020-04-18 05:01:06
问题 Hello guys I am trying to get TextBox Named "txtQty" value from DataGridTemplateColum Here is the code, Hope someone Helps me.... .XML <DataGrid x:Name="dataGridMain"> <DataGrid.Columns> <DataGridTextColumn Header="Id" Binding="{Binding Id}" IsReadOnly="True" Visibility="Hidden"/> <DataGridTextColumn Header="Name" Binding="{Binding PName}" IsReadOnly="True"/> <DataGridTemplateColumn Header="Qty" > <DataGridTemplateColumn.CellTemplate > <DataTemplate > <StackPanel Orientation="Horizontal">

How to bind MySQL table to datagrid in WPF app

眉间皱痕 提交于 2020-04-10 06:16:06
问题 I've come across this question a lot, but I can't seem to find a satisfying answer. I have a WPF app in c# with a connection to a remote MySQL database. My goal is to select a table from the database and present it in a datagrid. But after this I want to be able to print a selected row (using given report definition files). So I'm interested in a way to populate my datagrid (I know the mysql statements needed) without storing the mysql table locally in, say an ObservableCollection. I just

How to bind MySQL table to datagrid in WPF app

有些话、适合烂在心里 提交于 2020-04-10 06:11:34
问题 I've come across this question a lot, but I can't seem to find a satisfying answer. I have a WPF app in c# with a connection to a remote MySQL database. My goal is to select a table from the database and present it in a datagrid. But after this I want to be able to print a selected row (using given report definition files). So I'm interested in a way to populate my datagrid (I know the mysql statements needed) without storing the mysql table locally in, say an ObservableCollection. I just

How to bind MySQL table to datagrid in WPF app

人走茶凉 提交于 2020-04-10 06:11:00
问题 I've come across this question a lot, but I can't seem to find a satisfying answer. I have a WPF app in c# with a connection to a remote MySQL database. My goal is to select a table from the database and present it in a datagrid. But after this I want to be able to print a selected row (using given report definition files). So I'm interested in a way to populate my datagrid (I know the mysql statements needed) without storing the mysql table locally in, say an ObservableCollection. I just

Update single row in a WPF Datagrid

佐手、 提交于 2020-03-19 05:08:48
问题 I'm creating a download manager, and my WPF datagrid is bound to a collection of objects representing ongoing downloads (in separate threads). When I have multiple downloads running, each one is using this code to update its datagrid item every second: if (DateTime.Now > download.LastUpdateTime.AddSeconds(1)) { this.downloadsGrid.Items.Refresh(); download.LastUpdateTime = DateTime.Now; } Datagrid.Items.Refresh() does the job, but it reconstructs the whole datagrid, causing all downloads to

Not refreshing in WPF with DataGrid

霸气de小男生 提交于 2020-03-06 04:37:32
问题 Sorry, I have seen this questioned asked a couple of times here already, but none of the answers have solved my problem. public MainWindow() { _PropertyTenantData = new DataTable(); _PropertyTenantData.Columns.Add(new DataColumn("Property", typeof(string))); _PropertyTenantData.Columns.Add(new DataColumn("Tenant", typeof(string))); DBConnect RentalDatabase = new DBConnect(); List<string>[] list = new List<string>[2]; list = RentalDatabase.SelectPropertyTenant(); var row = _PropertyTenantData

Mouse scroll not working in a scroll viewer with a wpf datagrid and additional UI elements

好久不见. 提交于 2020-02-17 18:07:31
问题 I am trying to figure out how to get the mouse scroll working on a wpf window with a scrollviewer and a datagrid within it. The WPF and C# code is below <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Border Name="DataGridBorder" BorderThickness="2" Margin="1" CornerRadius="4" BorderBrush="#FF080757"> <dg:DataGrid AutoGenerateColumns="False"