A
A
aeaeae12020-12-20 16:39:13
C++ / C#
aeaeae1, 2020-12-20 16:39:13

How to remove all empty columns in dataGridView1 c#?

Can you please tell me how to remove all empty columns in dataGridView1?
Here I wrote the code. Tell me what's wrong?

for (int col = 0; col < dataGridView1.ColumnCount; col++)
            
                    if (dataGridView1.Columns[col].ToString() == string.Empty)
                    {
                        dataGridView1.Columns.RemoveAt(col);
                    }
            

        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fan92rus, 2020-12-21
@fan92rus

For data gridview, you can use mapping through DataSourse
Article https://blog.foolsoft.ru/c-datagridview-i-primery-...
And attribute for column title
[DisplayName("Creator")]
public string Title => "{ My_Title}";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question