Hi! I am making an employee scheduling system.
I have a datagridview that has 2 datagridviewcombobox columns
1. I populated the first combobox column with Weekdays (Monday, Tuesday etc)
2. The second is populated with Shift records from database.
How can I get the selected value of the datagridviewcombobox and store it in an array or variable.
I also want to get the ShiftID of the selected Shift on the 2nd datagridviewcombobox
Here is my code for populating the datagridviewcombobox.
Dim gridcombo As New DataGridViewComboBoxColumn
gridcombo.HeaderText = "Day"
gridcombo.Name = "day"
gridcombo.Items.Add("Monday")
gridcombo.Items.Add("Tuesday")
gridcombo.Items.Add("Wednesday")
gridcombo.Items.Add("Thursday")
gridcombo.Items.Add("Friday")
DataGridView2.Columns.Add(gridcombo)
Dim gridcombo1 As New DataGridViewComboBoxColumn
gridcombo1.HeaderText = "Shift"
gridcombo1.Name = "shift"
Dim a As String = "Select ShiftID, StartTime,EndTime from tblshift"
cmd = New MySqlCommand(a, con)
dr = cmd.ExecuteReader
While dr.Read
Dim starttime As String = Format(dr(1), "hh:mm tt")
Dim endtime As String = Format(dr(2), "hh:mm tt")
gridcombo1.Items.Add(starttime & "-" & endtime)
End While
DataGridView2.Columns.Add(gridcombo1)
I have a datagridview that has 2 datagridviewcombobox columns
1. I populated the first combobox column with Weekdays (Monday, Tuesday etc)
2. The second is populated with Shift records from database.
How can I get the selected value of the datagridviewcombobox and store it in an array or variable.
I also want to get the ShiftID of the selected Shift on the 2nd datagridviewcombobox
Here is my code for populating the datagridviewcombobox.
Quote:
Dim gridcombo As New DataGridViewComboBoxColumn
gridcombo.HeaderText = "Day"
gridcombo.Name = "day"
gridcombo.Items.Add("Monday")
gridcombo.Items.Add("Tuesday")
gridcombo.Items.Add("Wednesday")
gridcombo.Items.Add("Thursday")
gridcombo.Items.Add("Friday")
DataGridView2.Columns.Add(gridcombo)
Quote:
Dim gridcombo1 As New DataGridViewComboBoxColumn
gridcombo1.HeaderText = "Shift"
gridcombo1.Name = "shift"
Dim a As String = "Select ShiftID, StartTime,EndTime from tblshift"
cmd = New MySqlCommand(a, con)
dr = cmd.ExecuteReader
While dr.Read
Dim starttime As String = Format(dr(1), "hh:mm tt")
Dim endtime As String = Format(dr(2), "hh:mm tt")
gridcombo1.Items.Add(starttime & "-" & endtime)
End While
DataGridView2.Columns.Add(gridcombo1)