Search code examples
c#sqlwinformscheckboxsqlconnection

C# SQL Check box to be ticked when data present


I am slowing learning my way round c# and SQL. I have started a project that will have a list of checkboxes. I want these checkboxes to be ticked if there is any data present within the table. I am not interested in what data, only if there is data in the table.

I have created a win form project that can connect to the database and show the data in a grid view.

Any help would be fantastic!


Solution

  • Just set the Checked properties on the checkboxes.

    checkBox1.Checked = dataGridView1.Rows.Count > 0;
    

    It would help a huge amount and you will be more likely to get a better answer if you posted some things you have tried already or some examples of your code so far.