コード例 #1
0
        private void cargarCombo(ComboBox combo, string nombreTabla)
        {
            DataTable dt = new DataTable();

            dt = oDato.consultarTabla(nombreTabla);
            combo.DataSource    = dt;
            combo.ValueMember   = dt.Columns[0].ColumnName;
            combo.DisplayMember = dt.Columns[1].ColumnName;
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.SelectedIndex = -1;
        }
コード例 #2
0
        //RECUPERACION Y CARGA DE DATOS
        public void cargarCombo(ComboBox combo, string nombreTabla)
        {
            DataTable dtm = new DataTable();

            dtm = adm.consultarTabla(nombreTabla);
            combo.DataSource  = dtm;
            combo.ValueMember = dtm.Columns[0].ColumnName;
            if (nombreTabla == "Cliente")
            {
                combo.DisplayMember = dtm.Columns[2].ColumnName;
            }
            else
            {
                combo.DisplayMember = dtm.Columns[1].ColumnName;
            }
            combo.DropDownStyle = ComboBoxStyle.DropDownList;
            combo.SelectedIndex = -1;
        }