Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

[RESOLVED] Get value of the selected DataGridViewComboBox cell/column

$
0
0
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.

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)

Viewing all articles
Browse latest Browse all 27353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>