Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF C# with Npgsql DataGrid Columns with ComboBoxes with names instead of fkey values.

$
0
0

It all seemed so incredibly simple in WinForms, but now moving on to WPF I have come to realize that even creating a simple DataGrid with that is populated from DataTables that have many-to-many relationships might be not as easy as I wished it to be.

Main problem is that I have no time for learning the MVVM approach.

How far have I gotten? I have defined all of the DataTables that are filled from a PostgreSQL database, I have created a DataGrid that is bound to the corresponding tables, but I have a feeling that I am missing something.

There are to DataTables Cat and Country

For a foreign key column that had to be filled with country names instead of fkey numbers I used an observable collection, but unfortunately that is only as far as I have gotten.

The table fills up nicely, the ComboBox shows all of the values from the ObservableCollection, but since I need to add CRUD I added this to the SelectionChanged event of the ComboBox:

ComboBox comboBox = (ComboBox) sender;
        string test = comboBox.SelectedValue.ToString();

To get the chosen value.

Now how do I pass this value to the corresponding Row in the Cat table.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>