Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, it depends on how you want to do it. First off, I'm not a big fan of allowing direct access to controls on my user controls. For this reason, I make sure none of the controls are publically accessable. What I do is make everything private (or sometimes protected since it's nice for derived classes to have some flexibility) then I create properties to access the controls' properties that must be accessible and events to be handled by parent containers.</p> <p><del>If all that really doesn't matter to you, then I believe the property you are looking for is the Control.Locked property. In your code above once you've added the dynamic control to the Controls collection, set the Locked to true. So:</p> <pre><code> this.Controls.Add(rb); rb.Locked = true; </code></pre> <p></del> <br /> Try something like this:</p> <pre><code> public class RadioButtonProperties { private RadioButton _realtedRadioButton = new RadioButton(); public RadioButtonProperties(RadioButton radio) { _realtedRadioButton = radio; Name = radio.Name; Checked = radio.Checked; //add other properties } public string Name { get { //logic to to handle if checkbox is null here return _realtedRadioButton.Name; } set { //logic to to handle if checkbox is null here _realtedRadioButton.Name = value; } } public bool Checked { get { //logic to to handle if checkbox is null here return _realtedRadioButton.Checked; } set { //logic to to handle if checkbox is null here _realtedRadioButton.Checked = value; } } } </code></pre> <p>Now in your custom control, instead of giving public access to your entire radiobox array, you give access to a representation of the array, exposing only the radiobox properties that you want. For example:</p> <pre><code> [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public List&lt;RadioButtonProperties&gt; Items { get; set; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload