M
M
michadimin2021-12-11 20:20:28
C++ / C#
michadimin, 2021-12-11 20:20:28

How to use CheckBox in WinForms?

I want to make it so that when the checkbox is checked, the user has the opportunity to stretch the window (by default, this option is not available, it was done on purpose).

How many in the internet did not climb - could not find the answer.

Maybe someone here can help? Show how this can be done.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-12-11
@Adler_lug

For Checkbox there is an event - CheckedChanged that occurs when the state of the Checkbox changes.
In it, do what you need.

V
Voland69, 2021-12-11
@Voland69

Handle click on checkbox

private void checkBox1_Click(object sender, System.EventArgs e)  
{  
   // The CheckBox control's Text property is changed each time the
   // control is clicked, indicating a checked or unchecked state.  
   if (checkBox1.Checked)  
   {  
      checkBox1.Text = "Checked";  
   }  
   else  
   {  
      checkBox1.Text = "Unchecked";  
   }  
}

and toggle the window stretch mode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question