There are 2 tables, books and kinds connected by external key. The kinds table contains id and name columns. There is a kind column in the books table that refers to the id field in the kinds table.
Displays the contents of the books table.
How to make so that in the field of kind instead of id (from books) the name is output (from kinds)? Those. instead of the genre id, the book should display the genre name.
Moreover, when you click on the cell of the kind column, the ComboBox should appear, which contains all the name strings from B (a list of these very kinds, so that you can select and change them), i.e. as it happens, for example in SQLite studio DBMS when filling data

using System; using System.Windows.Forms; using Npgsql; namespace Automated_WorkPlace_Library { public partial class FormMain : Form { public NpgsqlConnection connection { get; set; } = null; public FormMain() { InitializeComponent(); } private void FormMain_Load(object sender, EventArgs e) { connection = ConnectToDB("test", "123"); connection.Open(); var adapter_Books = new NpgsqlDataAdapter("select * from books", connection); adapter_Books.Fill(DS_Books, "books"); var adapter_Kinds = new NpgsqlDataAdapter("select * from kinds", connection); adapter_Kinds.Fill(DS_Books, "kinds"); DS_Books.Relations.Add("kind_of_book", DS_Books.Tables["kinds"].Columns["id"], DS_Books.Tables["books"].Columns["kind"]); DGV_Books.DataSource = DS_Books.Tables[0]; connection.Close(); } } } 
  • See here . The essence is the same. - Alexander Petrov

0