datagrid

Getting data from a Datagrid back into SQL Server Database

家住魔仙堡 提交于 2019-12-25 08:25:15
问题 I apologise in advance because I know this is a very basic question for most of you, but I'm really struggling to find the relevant information I need and wondered if someone could send me in the right direction. I have a winforms app, and a SQLserver database. I know how to poulate various controls (including the datagrid) with data from my database. However, what I am struggling with, is how to get user's manipulation of data in the datagrid, back to the sql server database. Also I know how

VB.NET WPF How to get the column value from datagrid?

こ雲淡風輕ζ 提交于 2019-12-25 08:17:14
问题 So I am not quite familiar with WPF yet and in WinForms, you can have CellDoubleClick event which I can get the value like row.Cells("ID").Value.ToString() But in WPF, row is not a member of datagrid. So how can I get the value of the selected ID if user just double click on the row? Here is a picture to clarify my question. The record shown is from a datatable. When multiple row of records is shown, and the user double click on any of the row, how do I get the value of the selected row ID?

select a datagrid cell that contains a given value in wpf

泄露秘密 提交于 2019-12-25 07:58:51
问题 I bound a DataTable to a datagrid in wpf. The first column has unique values. Now I would like to autoselect a cell in the second column whose first column cell has the given value. How should I achieve that? For example,here is my datagrid: Name | Age cat | 2 dog | 3 When user input 'dog', I will need the '3' to be selected. I tried the method show here: How to select a row or a cell in WPF DataGrid programmatically? However, I cannot figure out the displaying row number. Even though I know

'EditItem' is not allowed for this view` when editing a detail item

你。 提交于 2019-12-25 07:49:48
问题 Context Using Entity Framework 6 I have an ObservableCollection of Airframe objects each of which has a subordinate collection of Identity objects. Through XAML and a view model I'm viewing this collection one airframe (master) at a time with each of it's Identity (detail) objects in a DataGrid. To handle the display / update of just one Airframe at a time I'm using a CollectionView so that I get current positioning within the collection and can wire up "Goto next" and "Goto previous" buttons

Flex s:DataGrid all ItemRenderer are fired

北城以北 提交于 2019-12-25 07:49:42
问题 I don't understand why when we change data on dataprovider , all the itemRenderers of the impacted column are called ? Here is a little example of my problem : application : <?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" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> <fx:Script> <![CDATA[ import mx.collections

How to add a button to the last/new row of a datagrid?

对着背影说爱祢 提交于 2019-12-25 07:39:29
问题 I would like to show a popup to help the users to add a new row to a datagrid, by adding a button in the last row of the datagrid. I figured there must be some sort of DataGridTemplateColumn property I have to set for the newrow/addrow template? 回答1: What you can do is to write a style for "DataGridRow" as Thi is the working example <Style x:Type="DataGridRow"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridRow}"> <Grid Background="{TemplateBinding

ObservableCollection with INotifyPropertyChanged into DatagridComboboxColumn Binding

淺唱寂寞╮ 提交于 2019-12-25 07:19:03
问题 My little project looks now quite different. Now I have ObservableCollection PackagesList with data which I want to bind with whole DataGrid (via Binding Path) and ObservableCollection DestinationItememsSource where I store cases for DataGridComboboxColumn (as ItemsSourceBinding). SelectedItem property in DatagridComboboxColumn is one value from PackageInfo (and it is one of DestinationNames cases ofc). Binding on DatagridTextBoxColumns is ok. XAML: <Window x:Class="test01.MainWindow" xmlns=

Binding properties (width/sorting) of DataGrid on dynamic TabPage

我只是一个虾纸丫 提交于 2019-12-25 07:09:31
问题 I've created a little wpf test project to demonstrate my question. This project contains a single wpf window. This window contains only a TabControl . The pages of this TabControl are created dynamically from the bound ItemSource . My XAML: <Window x:Name="window" x:Class="TestWpf.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:TestWpf" Title="MainWindow" Height="350" Width="525">

DataTable is not updating DataGrid after clearing and refilling data. MVVM

≯℡__Kan透↙ 提交于 2019-12-25 06:26:25
问题 My viewModel is: public class MainWindowViewModel { public MainWindowViewModel() { PopulateDataTable(); } private DataTable employeeDataTable; public DataTable EmployeeDataTable { get { return employeeDataTable; } set { employeeDataTable = value; OnPropertyChanged("EmployeeDataTable"); } } private void PopulateDataTable() { var _ds = new DataSet("Test"); employeeDataTable = new DataTable(); employeeDataTable = _ds.Tables.Add("DT"); for (int i = 0; i < 10; i++) { employeeDataTable.Columns.Add(

Calculate sum of a column in a datagridview c#

瘦欲@ 提交于 2019-12-25 05:32:40
问题 I created a program which calculates the sum of a column in a datagridview, the problem arises when I refactor the logic from the click handler into a separate a method. The calcSum method does not seem to give me the correct output compared with button2_Click which has all the logic directly in the click handler. Can anyone please point out what's wrong with my code? //Calls sum of column method, "incorrect" output private void button1_Click(object sender, EventArgs e){ calcSum(a,b,3); }