Grouping Windows Forms Radiobuttons with different parent controls in C#

前端 未结 4 1061
再見小時候
再見小時候 2021-01-11 19:30

I\'ve got a Windows Forms application in which I have a number of RadioButtons. These RadioButtons are placed within a FlowLayoutPanel which automatically arranges

4条回答
  •  长发绾君心
    2021-01-11 20:25

    I agree with @JonH - using tags is the cleanest way to do that (imho)

      private void FormLoad(object sender, EventArgs e)
      {
         radioCsv.Tag = DataTargetTypes.CsvFile;
         radioTabbed.Tag = DataTargetTypes.TxtFile;
         radioSas.Tag = DataTargetTypes.SasFile;
      }
    
      private void RadioButtonCheckedChanged(object sender, EventArgs e)
      {
         var radio = (RadioButton) sender;
         this.DataDestinationType = (DataTargetTypes)radio.Tag;
      }
    

提交回复
热议问题