how to set flag true to a checkbox RRS feed

  • Question

  • hi i have a checkbox if i click on the checkbox the flage has to return true otherwise false

    for example i have a windows form in that i have a checkbox and few textboxs. if i clcik on check box i want to disable remaining textboxs for that i have use flag .at the same time if click on check box i want to return true value


    Tuesday, June 21, 2011 10:32 AM


All replies

  • If I understand you correctly you have two questions. You want to know how to disable the other checkboxes when one is selected, and you want to know how to set a flag (or boolean?) to true once the checkbox is selected.

    First of all I would consider using radio buttons instead of checkboxes. You will have to assign them to the same group and then they will deselect the others in the group once you select one of them.

    As to your second question, I would use an event handler that, when the radio button is selected, causes an event to fire that sets the value you want to true.

    Hope this helps.

    Tuesday, June 21, 2011 1:00 PM
  • The Checked property (boolean) of the CheckBox returns the state of the checkbox (true or false).

    Handling the CheckedChanged event will allow you to write code to enable/disable controls when the Checkbox is checked/unchecked http://msdn.microsoft.com/en-us/library/system.windows.forms.checkbox.checkedchanged.aspx

    Please mark this as answer or vote as helpful if it solved your problem
    Tuesday, June 21, 2011 1:16 PM