I have datagridview
control and set source to datagridview
and add combobox column in datagridview
,now how can i set event (selectedindexchange)
combobox event to datagridview?
I want when i select present
then cell background color will be green
and when i select absent
then cell background color will be red
.Please tell me how can i do this?Check screenshot
VB.NET win forms code:
Dim query = "Select E.employee_id Employee_ID ,E.full_name Name,JI.Designitation "
query = query & " From Employee E"
query = query & " Inner Join Employee_Job_Info JI On E.employee_id = JI.Emp_ID"
query = query & " WHERE JI.Department='" & ComboBox1.SelectedValue.ToString() & "'"
Dim dt As DataTable
dt = getDataTable(query)
DGAttendance.DataSource = dt
If DGAttendance.Columns.Count <= 3 Then
Dim col As New DataGridViewComboBoxColumn
DGAttendance.Columns.Add(col)
col.DataPropertyName = "Att_Status"
col.HeaderText = "Status"
col.Name = "Attedence_Status"
col.Items.Add("Present")
col.Items.Add("Absent")
col.Items.Add("Leave")
col.DefaultCellStyle.BackColor = Color.Red
col.DefaultCellStyle.ForeColor = Color.White
End If