Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am going to develop a school management system and want to save attendance records in the database from DataGridViewComboBoxColumn each student in class with the Save button.

I mean set all student records e.g. present, absent, or leave the save record in the database when the "save" button is pressed.

This is my code - it works when I change cell of 1st student

What I have tried:

C#
private void AttendanceDataGridVies_CurrentCellDirtyStateChanged(object sender, EventArgs e)
    {
        AttendanceDataGridVies.CommitEdit(DataGridViewDataErrorContexts.Commit);
    }

    private void AttendanceDataGridVies_CellValueChanged(object sender, DataGridViewCellEventArgs e)
    {
        string comboboxSelectedValue = string.Empty;

        if (AttendanceDataGridVies.Columns[e.ColumnIndex].GetType() == typeof(DataGridViewComboBoxColumn))
        {
            comboboxSelectedValue = AttendanceDataGridVies.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
            label2.Text = comboboxSelectedValue;
        }
    }
Posted
Updated 15-Aug-20 8:37am
v2

1 solution

Seems you want to update SQB DB on click of save post making changes to combobox column.
If so, have a look at this sample here: ComboBox with DataGridView in C#[^]

Check out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900