Пример #1
0
 private void CidGroupRadioButton_ControlAdded(object sender, ControlEventArgs e)
 {
     if (e.Control is CIDRadioButton)
     {
         CIDRadioButton radio = (e.Control as CIDRadioButton);
         radio.CheckedChanged += radioButton_CheckedChanged;
         panelRadio.Controls.Add(radio);
     }
 }
Пример #2
0
        private void MostarRespuestas(int opcion)
        {
            try
            {
                if (opcion == 1)
                {
                    if (_pregunta.Respuesta.Count > 0)
                    {
                        CidGroupRadioButton group = new CidGroupRadioButton();
                        group.AutoSize = true;
                        group.Location = new Point(0, 0);
                        group.DataBindings.Add("SelectedValue", Model, "ValueGroupRadioButton", true, DataSourceUpdateMode.OnPropertyChanged);

                        foreach (var item in _pregunta.Respuesta)
                        {
                            CIDRadioButton _respuestas = new CIDRadioButton();
                            _respuestas.Value = item.IdRespuesta;
                            _respuestas.Text  = item.Respuesta;
                            group.Controls.Add(_respuestas);
                        }

                        this.flowLayoutPanel2.Controls.Add(group);
                    }
                }
                else if (opcion == 2)
                {
                    if (_pregunta.Respuesta.Count > 0)
                    {
                        //FlowLayoutPanel panelCheck = new FlowLayoutPanel();

                        var value = Model.ListaOpciones.OrderByDescending(x => x.IdRespuesta).ToList();
                        foreach (var item in value)
                        {
                            CheckBox _respuestas = new CheckBox();
                            _respuestas.Text = item.Respuesta;
                            //_respuestas.DataBindings.Add("Checked", item, "Seleccionado");
                            _respuestas.DataBindings.Add("Checked", item, "Seleccionado", true, DataSourceUpdateMode.OnPropertyChanged);
                            _respuestas.CheckedChanged += radioButton_CheckedChanged;
                            this.flowLayoutPanel3.Controls.Add(_respuestas);
                        }
                        //this.flowLayoutPanel3.Controls.Add(panelCheck);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            CIDRadioButton rb = sender as CIDRadioButton;

            if (rb == null)
            {
                return;
            }

            // Ensure that the RadioButton.Checked property
            // changed to true.
            if (rb.Checked)
            {
                // Keep track of the selected RadioButton by saving a reference
                // to it.
                SelectedValue = rb.Value;
            }
        }