Linking property to other property

I have nested group groups that logically represent nested data structures in my application. Say I have a structure like this:

Dev1  
- CDev1  
- CDev2  
    - ICDev1  
    - ICDev2

I have checkboxes to enable / disable each of these Dev. I want to bind the CheckState flag of a child to the parent CheckState flag. I want the mechanism to work as follows: When I test CDev2, ICDev1 and ICDev2 are automatically checked. But when I turn off ICDev1, CDev2 will remain in its own state. Basically, I want these events to apply to children, but not to the parent, as one-way binding.

I am using .Net 2.0 SP2. I don’t know if this is possible or not, so I would be glad if you showed me some directions about it. If this is not possible, I am going to implement event handlers for all flags.

+3
source share
5 answers

Try the following:

childCheckBox.DataBindings.Add("Checked", parentCheckBox, "Checked");

You can also look at the control TreeView, it can display CheckBoxnext to each element.

+5
source

WPF ( WPF). , WinForms. WinForms, , .

0

. ICDev1 ICDev2 CDev2, , ICDev1 , ICDev1 ICDev2 . , , ICDev1, ICDev2, CDev2. , ICDev1, ICDev2, .

0

This is possible in WPF, but I do not think it is possible in winforms, because there is no mechanism for updating property events, such as a dependency property, or INotifyPropertyChanged in WinForms

0
source

Look here and the link to the Truss library Kent Boogart, which generally bypasses the winners. This may require some subclass though, depending on your model, as it works similar to wpf binding.

0
source

Source: https://habr.com/ru/post/1713662/


All Articles