mercredi 15 janvier 2020

Reading the checkboxes and insert into the database

everybody, I have a problem regarding my project for a digital class register. In the following project the data from the third column of the datagrid has to be read in via a checkbox and sent to a database. I am glad about any help. Please adapt the code to the project.

    private void SetupDataGridView()
    {
        this.Controls.Add(KLDataGridView);

        KLDataGridView.ColumnCount = 2;

        KLDataGridView.ColumnHeadersDefaultCellStyle.BackColor = Color.Black;
        KLDataGridView.ColumnHeadersDefaultCellStyle.ForeColor = Color.Red;
        KLDataGridView.ColumnHeadersDefaultCellStyle.Font =
            new Font(KLDataGridView.Font, FontStyle.Bold);


        KLDataGridView.DefaultCellStyle.ForeColor = Color.Black;
        KLDataGridView.DefaultCellStyle.Font = new Font("Lucida Sans Unicode", 15);


        KLDataGridView.Name = "Klassenliste";
        KLDataGridView.Location = new Point(8, 8);
        KLDataGridView.Size = new Size(600, 300);
        KLDataGridView.AutoSizeRowsMode =
            DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
        KLDataGridView.ColumnHeadersBorderStyle =
            DataGridViewHeaderBorderStyle.Single;
        KLDataGridView.CellBorderStyle = DataGridViewCellBorderStyle.Single;
        KLDataGridView.GridColor = Color.Black;
        KLDataGridView.RowHeadersVisible = false;

        DataGridViewCheckBoxColumn CheckBoxColumn = new DataGridViewCheckBoxColumn();



        KLDataGridView.Columns[0].Name = "Vorname";
        KLDataGridView.Columns[1].Name = "Nachname";
        CheckBoxColumn.HeaderText = "Nicht Anwesend";
        KLDataGridView.Columns.Add(CheckBoxColumn);
        KLDataGridView.MultiSelect = true;
        KLDataGridView.Dock = DockStyle.Fill;
    }
    private void PopulateDataGridView()
    {

        KLDataGridView.Rows[0].Cells[0].Value = SQLConnection.sql("select vorname from schueler where skennung = 'SFI17301';");



        KLDataGridView.Columns[0].DisplayIndex = 0;
        KLDataGridView.Columns[1].DisplayIndex = 1;
        KLDataGridView.Columns[2].DisplayIndex = 2;
        KLDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
    }



Aucun commentaire:

Enregistrer un commentaire