'Add data by clicking on a cell in a datagriview vb net or c #

I am trying to add data to any cell that the user clicks temporarily in my datagriview.

My calendar datagrdview is populated from SQL with a stored procedure like this

CapaDatos_Hours:

   Public Function Listar_Calendario(ByVal base As String, ByVal periodo As String, ByVal ptoventa As String, ByVal area As String) As DataTable
    Dim dt As New DataTable
    Try
        Dim cnn As New SqlConnection(conexion.CargarBase(base))
        Dim cmd As New SqlCommand("execute AUT_HORARIOS @tipo='6',@PERIODO='" & periodo & "',@PTOVTA='" & ptoventa & "',@IDAREA='" & area & "'", cnn)
        Dim da As New SqlDataAdapter(cmd)
        Try
            If cnn.State = ConnectionState.Closed Then
                cnn.Open()
            Else
                cnn.Close()
                cnn.Open()
            End If
            da.Fill(dt)
        Catch ex As SqlClient.SqlException : Throw ex
        Finally
            cnn.Close()
        End Try
    Catch ex1 As Exception : Throw ex1
    End Try
    Return dt
End Function

In the form I call this function and populate my datagriview like this

Sub poblar_calendario()
    Me.DGVDETASIGNACION.DataSource = negHor.Listar_Calendarios(VGlobales.Base, Me.cboperiodo.SelectedValue, Me.cboptoventa.SelectedValue, Me.cboareas.SelectedValue)
    Me.DGVDETASIGNACION.Columns(0).Frozen = True
    Me.DGVDETASIGNACION.Columns(1).Frozen = True
    Me.DGVDETASIGNACION.Columns(2).Frozen = True
    Me.DGVDETASIGNACION.Columns(3).Frozen = True
    Me.DGVDETASIGNACION.Columns(4).Frozen = True

End Sub

and it looks like this

enter image description here

What I want is that when the user clicks on any cell, the shift that is selected is added, this would be added temporarily in the datagridview.

When selecting the shift or the schedule and I click on any cell it is added, and thus go adding in any cell progressively and it fills the days of the week or the cells with the schedule that I select.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source