Beispiel #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.Columns[e.ColumnIndex].Name.Contains("idHorario"))
            {
                DataGridViewComboBoxCell comboBP = new DataGridViewComboBoxCell();
                dataGridView1[e.ColumnIndex, e.RowIndex] = comboBP;
                comboBP.Style.BackColor          = SystemColors.Control;
                comboBP.Style.SelectionBackColor = SystemColors.Control;
                comboBP.Style.SelectionForeColor = SystemColors.Control;

                ConexionHorarios conexionH = new ConexionHorarios();
                int[]            ids;
                DataTable        table = new DataTable();
                table.Columns.Add("idHorario", typeof(int));
                ids = conexionH.ConsultIds();
                foreach (int i in ids)
                {
                    table.Rows.Add(i);
                }
                comboBP.ValueMember   = "idHorario";
                comboBP.DisplayMember = "idHorario";
                comboBP.DataSource    = table;
            }
            else if (dataGridView1.Columns[e.ColumnIndex].Name.Contains("idCliente"))
            {
                DataGridViewComboBoxCell comboBP = new DataGridViewComboBoxCell();
                dataGridView1[e.ColumnIndex, e.RowIndex] = comboBP;
                comboBP.Style.BackColor          = SystemColors.Control;
                comboBP.Style.SelectionBackColor = SystemColors.Control;
                comboBP.Style.SelectionForeColor = SystemColors.Control;

                ConexionClientes conexionC = new ConexionClientes();
                int[]            ids;
                DataTable        table = new DataTable();
                table.Columns.Add("idCliente", typeof(int));
                ids = conexionC.ConsultIds();
                foreach (int i in ids)
                {
                    table.Rows.Add(i);
                }
                comboBP.ValueMember   = "idCliente";
                comboBP.DisplayMember = "idCliente";
                comboBP.DataSource    = table;
            }
        }
        void LoadCombos()
        {
            ConexionClientes conexionClientes = new ConexionClientes();
            ConexionHorarios conexionHorarios = new ConexionHorarios();

            int[] idsClientes = conexionClientes.ConsultIds();

            for (int i = 0; i < idsClientes.Length; i++)
            {
                cBoxClientes.Items.Add(idsClientes[i]);
            }

            int[] idsHorarios = conexionHorarios.ConsultIds();
            for (int i = 0; i < idsHorarios.Length; i++)
            {
                comboBoxHorario.Items.Add(idsHorarios[i]);
            }
        }