I need to convert a field from a bindinglist to combobox

0

This is the code that is not working:

public class DetalleTurnoPersonal
    {
        public string Nombre  { get; set; }
        public DateTime Fecha_Entrada { get; set; }
        public TimeSpan Hora_Entrada { get; set; }
        public DateTime Fecha_Salida { get; set; }
        public TimeSpan Hora_Salida { get; set; }
        public string Sector { get; set; }
        public int IDSeccion { get; set; }
        public int IDEmpresa { get; set; }


    }

and on the other hand I take it with a bindinglist

private readonly BindingList<DetalleTurnoPersonal> misDetalles = new BindingList<DetalleTurnoPersonal>();
        public FrmTurnosTransferPersonal()
        {
            InitializeComponent();

        }

DetalleTurnoPersonal miDetalle = new DetalleTurnoPersonal();

 miDetalle.Nombre = NombrePersona;
                miDetalle.Hora_Entrada = TimeSpan.Parse(horaEntradaComboBox.Text);
                miDetalle.Fecha_Entrada = Convert.ToDateTime(FechadateTimePicker.Value.ToShortDateString());
                miDetalle.Hora_Salida = TimeSpan.Parse(HoraSalidacomboBox.Text);
                miDetalle.Fecha_Salida = Convert.ToDateTime(DateTime.Now.AddDays(1).ToShortDateString());
                miDetalle.Sector = Personalxnombre.Sector;
                miDetalle.IDSeccion = personalxnombre.IDSeccion;
                miDetalle.IDEmpresa = UsuarioLogueado.IDEmpresa;
                misDetalles.Add(miDetalle);

the field that I want to be displayed in the grid as a combobox is midetalle.sector

    
asked by Luis hernandez tejeda 16.06.2017 в 18:35
source

1 answer

0

try putting something like this:

combobox1.DataSource=misDetalles;
combobox1.DisplayMember="Sector";

I hope this can help you

    
answered by 16.06.2017 в 19:04