There is a base in the access, and the c # application, on the form of 2 grids, on the left of the accessory base, on the right, added the grid itself, which is not tied to any table. How to make, that in the second table row and column headers are filled with selected rows in 1 table? I tried to do this:
//Определяем количество выбраных строк int n = t1DataGridView.SelectedRows.Count; //Создаем массив этого размера для хранения названий строк string[] labels = new string[n]; DataTable dt = new DataTable(); dataGridView1.DataSource = dt; for (int i = 0; i < n; i++) { labels[i]=Convert.ToString(t1DataGridView.SelectedRows[i].Cells[0].Value); } for (int i = 0; i < n; i++) { dt.Columns.Add(labels[i]); dt.Rows.Add(); dataGridView1.Rows[i].HeaderCell.Value = labels[i]; } But for some reason only the last line header is saved. How to make, that all headings in line are displayed? on the columns, everything seems to be normal.