There is a basic form for lists. Wrote a procedure that calls the table function of the desired list depending on the idTab parameter passed. In the displayed lists, 4 columns are the same, the others differ in name, quantity of data and total count. The first 4 I add statically in the designer, and how can I add the rest dynamically, depending on the selected list?

  • one
    DataGridView? Do you generate data yourself or take it from somewhere? If you take, how you load, through assignment Items or through DataSource? - Andrew
  • @Andrew Yes, DataGridView, I take from tables, through DataSource - takecaretakecaretakecare
  • In general, the actions you perform in the designer are recorded as code in a file of the form <имя_Ρ„ΠΎΡ€ΠΌΡ‹>.Designer.cs . There you can see the code that adds the first four columns and, based on it, write your own. - default locale
  • And so that you can answer here you need to paint the question in more detail. Make an example, point out in steps what exactly you are doing, and then the details from the story are unclear. And also, what does DevExpress have to do with it? - default locale

1 answer 1

If we consider that:

  • Datagridview
  • data through dataSource

It should be something like that, but did not check:

 DataGridViewColumn column = new DataGridViewTextBoxColumn();// ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ ΠΊΠΎΠ»ΠΎΠ½ΠΊΡƒ column.DataPropertyName = "Name";//имя column.Name = "Knight"; //Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΎΠΊ ΠΊΠΎΠ»ΠΎΠ½ΠΊΠΈ column.DataPropertyName = "GoodGuy";//привязка ΠΊ ΠΏΡ€ΠΎΠΏΠ΅Ρ€Ρ‚ΠΈ ΠΎΠ±ΡŒΠ΅ΠΊΡ‚Π° ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ Π½ΡƒΠΆΠ½ΠΎ ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Ρ‚ΡŒ dataGridView1.Columns.Add(column);