Home > Net >  WPF get custom columns in the DataGrid TextBox value
WPF get custom columns in the DataGrid TextBox value

Time:09-28



I am using WPF, the column of text box is my custom to go up, then I have to be the new operation here, in the background for the line of the corresponding columns of text box I choose their own value, but now I can only get to later input values in the text box, I also tried to get the value of a column, using the code

Int result=the Convert. ToInt32 (mySelectedElement. Row [0]);> , but can only get from database queries, can't get custom,

Do you have what method can get into this value, bother to code, I am a rookie, also don't know much about the theory, thank you for your attention

CodePudding user response:

Use MVVM, input interface binding of the value of the background data source is updated directly, don't need that trouble to the interface

CodePudding user response:

Using MVVM is very convenient to solve this problem, you
Don't consider this way to obtain: DataRowView mySelectedElement=(DataRowView) dataGrid1. SelectedItem;
In need of new lines, the DataGrid ObservableCollection Data binding, the value of your custom controls don't read the data, then single binding,
{Binding you need to get the attribute value, Mode=OneWayToSource}
So you the background to obtain ObservableCollection Data source data can get custom controls,

CodePudding user response:

WPF is don't want to go Winform that through controls access to data, based on "data binding mechanism put focus on data processing, see # 2's advice,
  •  Tags:  
  • C#
  • Related