A
A
aeaeae12020-12-28 01:01:39
C++ / C#
aeaeae1, 2020-12-28 01:01:39

How to check if a column exists in a DataGridView?

How to set condition in datagridview c# if column exists then make it invisible? Let's say I have a column Column1. If it is present, it will become invisible. And if it is not, there will be an error. How to make a check for its presence and, if it is present, make it invisible?
dataGridView1.Columns["Column1"].Visible = false;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-12-28
@aeaeae1

if(dataGridView.Columns.Contains("Column1"))
 dataGridView.Columns["Column1"]. Visible = false;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question