c# - Are there multiple ways to group radio buttons in Windows Forms? -


i have few radio buttons in form should connected, want 1 of them in separate container group other related inputs. here general look:

radio button inputs

is there way group fourth radio button other 3 though in own group box?

fact radio buttons mutually exclusive when within same parent. being said can think of 2 options.

  1. let them in same parent, handle paint event of parent , draw manually giving impression different groups.
  2. you have manually manage mutual exclusion :(

radiobuttons no magic, set checked property of other radio's false behind scenes.

private list<radiobutton> radiobuttons = new list<radiobutton>(); //populate radios interested, call hookupevents , should work  private void hookupevents() {     foreach(var radio in radiobuttons)     {         radio.checkedchanged -= performmutualexclusion;         radio.checkedchanged += performmutualexclusion;     } }  private void performmutualexclusion(object sender, eventargs e) {     radio senderradio = (radiobutton)sender;     if(!senderradio.checked)     {         return;     }     foreach(var radio in radiobuttons)     {         if(radio == sender || !radio.checked)         {             continue;         }         radio.checked = false;     } } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -