Yes sure I have the code listed below - this seems to happening with all three of my comboboxes now. But I will give you the department combo box
There is on thing that is strange with this is - I've noticed it is a bit inconsistant.
If if I type C - takes me to the first occurance of C and highlights it and stays there. But the list still has department names starting with D, etc.
If I type CAT - same thing
But if type HYT - it doesn't react the same way - it selects the entry and then continues thru the subroutine. I get a messageshow popup telling me the department is locked. Also what is strange is it comes up twice - I traced the code thru and it is going thru the cboDepartment.SelectIndexChanged twice - but I havn't selected it a second time.
-------------------------------
'
' load the timesheet form
'
Private Sub Timesheet_Entry_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
If My.Computer.Screen.Bounds.Height < Me.Height Then
Me.Height = My.Computer.Screen.Bounds.Height - 25
End If
If My.Computer.Screen.Bounds.Width < Me.Width Then
Me.Width = My.Computer.Screen.Bounds.Width - 25
End If
'TODO: This line of code loads data into the '_keyscan_payrollDataSet.Supervisor_Reason_Xref' table. You can move, or remove it, as needed.
Me.Supervisor_Reason_XrefTableAdapter.Fill(Me._keyscan_payrollDataSet.Supervisor_Reason_Xref)
Create_Panels_And_Contols()
'TODO: This line of code loads data into the '_keyscan_payrollDataSet.PPStartDate' table. You can move, or remove it, as needed.
Me.PPStartDateTableAdapter.Fill(Me._keyscan_payrollDataSet.PPStartDate)
''TODO: This line of code loads data into the 'HYLTDDataSet.CPY10050' table. You can move, or remove it, as needed.
'Me.CPY10050TableAdapter.Fill(Me.HYLTDDataSet.CPY10050)
'TODO: This line of code loads data into the 'HYLTDDataSet.CPY10020' table. You can move, or remove it, as needed.
Me.CPY10020TableAdapter.Fill(Me.HYLTDDataSet.CPY10020)
''TODO: This line of code loads data into the 'HYLTDDataSet.CPY10100' table. You can move, or remove it, as needed.
'Me.CPY10100TableAdapter.Fill(Me.HYLTDDataSet.CPY10100)
Me.Refresh()
End Sub
---------------------------------------------
'
'declare an array of labels
'
Private Sub Create_Panels_And_Contols()
'
'creates 2 panels with controls for headings for the week
'
Dim x As Integer
Dim TabIndexCount As Integer
'initialize the panel
Dim PanelXaxis As Integer = 5
Dim PanelYaxis As Integer = 120
Dim PanelWidth As Integer = 115
Dim PanelLength As Integer = 275
'create panels and controls
For x = 1 To 2
pnlHeading(x) = New Panel
LabelWeek(x) = New Label
LabelDate(x) = New Label
LabelFSI(x) = New Label
LabelLSO(x) = New Label
LabelTotSwipe(x) = New Label
LabelReg(x) = New Label
LabelAdj1(x) = New Label
LabelAdj2(x) = New Label
LabelAdj3(x) = New Label
LabelTotTime(x) = New Label
pnlHeading(x).SetBounds(PanelXaxis, PanelYaxis, PanelWidth, PanelLength)
Me.Controls.Add(Me.pnlHeading(x))
'Add Controls to Heading Panel
Me.LabelWeek(x).SetBounds(5, 5, 95, 20)
Me.LabelDate(x).SetBounds(5, 32, 95, 20)
Me.LabelFSI(x).SetBounds(5, 58, 95, 20)
Me.LabelLSO(x).SetBounds(5, 84, 95, 20)
Me.LabelTotSwipe(x).SetBounds(5, 110, 95, 20)
Me.LabelReg(x).SetBounds(5, 136, 95, 20)
Me.LabelAdj1(x).SetBounds(5, 162, 95, 20)
Me.LabelAdj2(x).SetBounds(5, 188, 95, 20)
Me.LabelAdj3(x).SetBounds(5, 214, 95, 20)
Me.LabelTotTime(x).SetBounds(5, 240, 95, 20)
Me.pnlHeading(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelWeek(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelDate(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelFSI(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelLSO(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelTotSwipe(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelReg(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelAdj1(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelAdj2(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelAdj3(x).BorderStyle = BorderStyle.Fixed3D
Me.LabelTotTime(x).BorderStyle = BorderStyle.Fixed3D
'Add Text
If x = 1 Then
Me.LabelWeek(x).Text = "Week 1"
Me.LabelWeek(x).Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold)
Else
Me.LabelWeek(x).Text = "Week 2"
Me.LabelWeek(x).Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold)
End If
Me.LabelDate(x).Text = "Date"
Me.LabelFSI(x).Text = "First Swipe In"
Me.LabelLSO(x).Text = "Last Swipe Out"
Me.LabelTotSwipe(x).Text = "Total Swipe"
Me.LabelReg(x).Text = "Reg Time"
Me.LabelAdj1(x).Text = "Adjust 1"
Me.LabelAdj2(x).Text = "Adjust 2"
Me.LabelAdj3(x).Text = "Adjust 3"
Me.LabelTotTime(x).Text = "Total Time"
'Create Controls
Me.pnlHeading(x).Controls.Add(Me.LabelWeek(x))
Me.pnlHeading(x).Controls.Add(Me.LabelDate(x))
Me.pnlHeading(x).Controls.Add(Me.LabelFSI(x))
Me.pnlHeading(x).Controls.Add(Me.LabelLSO(x))
Me.pnlHeading(x).Controls.Add(Me.LabelTotSwipe(x))
Me.pnlHeading(x).Controls.Add(Me.LabelReg(x))
Me.pnlHeading(x).Controls.Add(Me.LabelAdj1(x))
Me.pnlHeading(x).Controls.Add(Me.LabelAdj2(x))
Me.pnlHeading(x).Controls.Add(Me.LabelAdj3(x))
Me.pnlHeading(x).Controls.Add(Me.LabelTotTime(x))
If x = 1 Then
PanelXaxis = 5
PanelYaxis = 405
End If
Next
'
'creates 14 panels with controls to correspond to 14 days in the payperiod
'
Me.Supervisor_Reason_XrefTableAdapter.Fill(Me._keyscan_payrollDataSet.Supervisor_Reason_Xref)
'initialize the panel
PanelXaxis = 120
PanelYaxis = 120
PanelWidth = 165
PanelLength = 275
'create panels and controls
x = 1
For x = 1 To 14
Me.pnlPPDay(x) = New Panel
Me.lblPPDay(x) = New Label
Me.lblFSI(x) = New Label
Me.lblLSO(x) = New Label
Me.lblTotSwipe(x) = New Label
Me.lblRegTime(x) = New Label
Me.txtAdjHour1(x) = New MaskedTextBox
Me.cboAdjMin1(x) = New ComboBox
Me.cboAdjReason1(x) = New ComboBox
Me.txtAdjHour2(x) = New MaskedTextBox
Me.cboAdjMin2(x) = New ComboBox
Me.cboAdjReason2(x) = New ComboBox
Me.txtAdjHour3(x) = New MaskedTextBox
Me.cboAdjMin3(x) = New ComboBox
Me.cboAdjReason3(x) = New ComboBox
Me.lblTotDayTime(x) = New Label
Me.pnlPPDay(x).SetBounds(PanelXaxis, PanelYaxis, PanelWidth, PanelLength)
Me.Controls.Add(Me.pnlPPDay(x))
'Add Controls to Panel
Me.lblPPDay(x).SetBounds(5, 32, 153, 20)
Me.lblFSI(x).SetBounds(5, 58, 40, 20)
Me.lblLSO(x).SetBounds(5, 84, 40, 20)
Me.lblTotSwipe(x).SetBounds(5, 110, 40, 20)
Me.lblRegTime(x).SetBounds(5, 136, 40, 20)
Me.txtAdjHour1(x).SetBounds(5, 162, 20, 20)
Me.cboAdjMin1(x).SetBounds(30, 162, 40, 20)
Me.cboAdjReason1(x).SetBounds(73, 162, 85, 20)
Me.txtAdjHour2(x).SetBounds(5, 188, 20, 20)
Me.cboAdjMin2(x).SetBounds(30, 188, 40, 20)
Me.cboAdjReason2(x).SetBounds(73, 188, 85, 20)
Me.txtAdjHour3(x).SetBounds(5, 214, 20, 20)
Me.cboAdjMin3(x).SetBounds(30, 214, 40, 20)
Me.cboAdjReason3(x).SetBounds(73, 214, 85, 20)
Me.lblTotDayTime(x).SetBounds(5, 240, 40, 20)
'Create border
Me.pnlPPDay(x).BorderStyle = BorderStyle.Fixed3D
Me.lblPPDay(x).BorderStyle = BorderStyle.Fixed3D
Me.lblFSI(x).BorderStyle = BorderStyle.Fixed3D
Me.lblLSO(x).BorderStyle = BorderStyle.Fixed3D
Me.lblTotSwipe(x).BorderStyle = BorderStyle.Fixed3D
Me.lblRegTime(x).BorderStyle = BorderStyle.Fixed3D
Me.txtAdjHour1(x).BorderStyle = BorderStyle.Fixed3D
Me.txtAdjHour2(x).BorderStyle = BorderStyle.Fixed3D
Me.txtAdjHour3(x).BorderStyle = BorderStyle.Fixed3D
Me.lblTotDayTime(x).BorderStyle = BorderStyle.Fixed3D
'background color
Me.lblPPDay(x).BackColor = Color.LightGray
Me.lblFSI(x).BackColor = Color.LightGray
Me.lblLSO(x).BackColor = Color.LightGray
Me.lblTotSwipe(x).BackColor = Color.LightGray
Me.lblRegTime(x).BackColor = Color.LightGray
Me.lblTotDayTime(x).BackColor = Color.LightGray
'tabstop property
Me.pnlPPDay(x).TabStop = False
Me.lblPPDay(x).TabStop = False
Me.lblFSI(x).TabStop = False
Me.lblLSO(x).TabStop = False
Me.lblTotSwipe(x).TabStop = False
Me.lblRegTime(x).TabStop = False
Me.lblTotDayTime(x).TabStop = False
'set tabstop index
Select Case x
Case 1
TabIndexCount = 0
Case 2
TabIndexCount = 9
Case 3
TabIndexCount = 18
End Select
Me.txtAdjHour1(x).TabIndex = 5 + TabIndexCount
Me.cboAdjMin1(x).TabIndex = 6 + TabIndexCount
Me.cboAdjReason1(x).TabIndex = 7 + TabIndexCount
Me.txtAdjHour2(x).TabIndex = 8 + TabIndexCount
Me.cboAdjMin2(x).TabIndex = 9 + TabIndexCount
Me.cboAdjReason2(x).TabIndex = 10 + TabIndexCount
Me.txtAdjHour3(x).TabIndex = 11 + TabIndexCount
Me.cboAdjMin3(x).TabIndex = 12 + TabIndexCount
Me.cboAdjReason3(x).TabIndex = 13 + TabIndexCount
Me.txtAdjHour1(x).Mask = "00"
Me.txtAdjHour2(x).Mask = "00"
Me.txtAdjHour3(x).Mask = "00"
' add handlers
AddHandler Me.txtAdjHour1(x).Validating, AddressOf txtAdjHours_Validating
AddHandler Me.txtAdjHour2(x).Validating, AddressOf txtAdjHours_Validating
AddHandler Me.txtAdjHour3(x).Validating, AddressOf txtAdjHours_Validating
AddHandler Me.cboAdjMin1(x).Validating, AddressOf cboAdjMin_Validating
AddHandler Me.cboAdjMin2(x).Validating, AddressOf cboAdjMin_Validating
AddHandler Me.cboAdjMin3(x).Validating, AddressOf cboAdjMin_Validating
'add table names
Me.txtAdjHour1(x).Name = "txtAdjHour1"
Me.txtAdjHour2(x).Name = "txtAdjHour2"
Me.txtAdjHour3(x).Name = "txtAdjHour3"
Me.cboAdjMin1(x).Name = "cboAdjMin1"
Me.cboAdjMin2(x).Name = "cboAdjMin2"
Me.cboAdjMin3(x).Name = "cboAdjMin3"
Me.cboAdjReason1(x).Name = "cboAdjReason1"
Me.cboAdjReason2(x).Name = "cboAdjReason2"
Me.cboAdjReason3(x).Name = "cboAdjReason3"
'Create Controls
Me.pnlPPDay(x).Controls.Add(Me.lblPPDay(x))
Me.pnlPPDay(x).Controls.Add(Me.lblFSI(x))
Me.pnlPPDay(x).Controls.Add(Me.lblLSO(x))
Me.pnlPPDay(x).Controls.Add(Me.lblTotSwipe(x))
Me.pnlPPDay(x).Controls.Add(Me.lblRegTime(x))
Me.pnlPPDay(x).Controls.Add(Me.txtAdjHour1(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjMin1(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjReason1(x))
Me.pnlPPDay(x).Controls.Add(Me.txtAdjHour2(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjMin2(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjReason2(x))
Me.pnlPPDay(x).Controls.Add(Me.txtAdjHour3(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjMin3(x))
Me.pnlPPDay(x).Controls.Add(Me.cboAdjReason3(x))
Me.pnlPPDay(x).Controls.Add(Me.lblTotDayTime(x))
'Add data to Reason Combo Boxes
Dim ReasonCode As String
Dim dr As DataRow
For count As Integer = 0 To _keyscan_payrollDataSet.Supervisor_Reason_Xref.Rows.Count - 1
dr = _keyscan_payrollDataSet.Supervisor_Reason_Xref(count)
ReasonCode = Trim(dr.Item("SupReasonCode").ToString)
If ReasonCode = "REG" Then
StoreRegIndex = count
End If
Me.cboAdjReason1(x).Items.Add(ReasonCode)
Me.cboAdjReason2(x).Items.Add(ReasonCode)
Me.cboAdjReason3(x).Items.Add(ReasonCode)
Next count
Me.cboAdjReason1(x).SelectedIndex = StoreRegIndex
Me.cboAdjReason2(x).SelectedIndex = StoreRegIndex
Me.cboAdjReason3(x).SelectedIndex = StoreRegIndex
'Add data to Hour and Minute Comboboxes
'Dim cbominsvalues() As String = {"00", "15", "30", "45", "-15", "-30", "-45"}
Dim cbominsvalues() As String = {"00", "15", "30", "45"}
Me.cboAdjMin1(x).Items.AddRange(cbominsvalues)
Me.cboAdjMin2(x).Items.AddRange(cbominsvalues)
Me.cboAdjMin3(x).Items.AddRange(cbominsvalues)
'set autocomplete criteria
Me.cboAdjMin1(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjMin2(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjMin3(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjReason1(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjReason2(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjReason3(x).AutoCompleteSource = AutoCompleteSource.ListItems
Me.cboAdjMin1(x).AutoCompleteMode = AutoCompleteMode.Suggest
Me.cboAdjMin2(x).AutoCompleteMode = AutoCompleteMode.Suggest
Me.cboAdjMin3(x).AutoCompleteMode = AutoCompleteMode.Suggest
Me.cboAdjReason1(x).AutoCompleteMode = AutoCompleteMode.Suggest
Me.cboAdjReason2(x).AutoCompleteMode = AutoCompleteMode.Suggest
Me.cboAdjReason3(x).AutoCompleteMode = AutoCompleteMode.Suggest
'set dropdown style to dropdown list only
Me.cboAdjMin1(x).DropDownStyle = ComboBoxStyle.DropDownList
Me.cboAdjMin2(x).DropDownStyle = ComboBoxStyle.DropDownList
Me.cboAdjMin3(x).DropDownStyle = ComboBoxStyle.DropDownList
Me.cboAdjReason1(x).DropDownStyle = ComboBoxStyle.DropDownList
Me.cboAdjReason2(x).DropDownStyle = ComboBoxStyle.DropDownList
Me.cboAdjReason3(x).DropDownStyle = ComboBoxStyle.DropDownList
'change panel location to show start of week 2
PanelXaxis = PanelXaxis + PanelWidth
If x = 7 Then
PanelXaxis = 120
PanelYaxis = 405
End If
Next x
End Sub
--------------------------------------------
Private Sub cboDepartment_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboDepartment.SelectedIndexChanged
Dim DepartmentLocked As Boolean
Dim drv As DataRowView = CType(cboDepartment.SelectedItem, DataRowView)
If drv Is Nothing Then
Exit Sub
End If
PDepartment = Trim(drv.Item("PDepartment").ToString)
'retrieve Department Lock file
Dim SQLString As String = "Server=SQL1;Database=keyscan-payroll;Uid=sa;Pwd=sysadmin;Connect Timeout=15"
Dim sqlConnection1 As New SqlClient.SqlConnection(SQLString)
Dim cmd As New SqlClient.SqlCommand
Dim ReturnValue1 As Decimal
cmd.CommandText = "SELECT DepartmentLock from Departmentlock where PDepartment = '" & PDepartment & "'"
cmd.CommandType = CommandType.Text
cmd.Connection = sqlConnection1
' Execute SQL command
sqlConnection1.Open()
ReturnValue1 = Convert.ToDecimal(cmd.ExecuteScalar)
sqlConnection1.Close()
cmd.Dispose()
sqlConnection1.Dispose()
DepartmentLocked = CBool(ReturnValue1)
If DepartmentLocked = True Then
MessageBox.Show("Payroll has been started. Please contact Payroll Department if you have any changes", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.cboDepartment.Focus()
Else
'TODO: This line of code loads data into the 'HYLTDDataSet.CPY10100' table. You can move, or remove it, as needed.
Me.CPY10100TableAdapter.FillByDepartment(Me.HYLTDDataSet.CPY10100, PDepartment)
'CPY10100BindingSource.Filter = "PDepartment = '" & PDepartment & "' And PInactive = 0"
lblTotEmpCount.Text = Me.cboEmployee.Items.Count.ToString
End If
End Sub
--------------------------------------------------
This is from the designer
'
'cboDepartment
'
Me.cboDepartment.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest
Me.cboDepartment.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems
Me.cboDepartment.DataSource = Me.CPY10020BindingSource
Me.cboDepartment.DisplayMember = "PDescription"
Me.cboDepartment.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboDepartment.FormattingEnabled = True
Me.cboDepartment.Location = New System.Drawing.Point(132, 62)
Me.cboDepartment.Name = "cboDepartment"
Me.cboDepartment.Size = New System.Drawing.Size(182, 21)
Me.cboDepartment.TabIndex = 3
'
---------------------------------------
Thanks for the help
Kim