The code below is for the combo box to retrieve items from the database. But now the problem I face is in the
Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox.(from the code).
For the
Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox,
the error is 'CatCodeComboBox is already declared as 'FriendWithEvents CatCodeComboBox As System.Windows.Forms.ComboBox' in this class. I do not know why this error has popped up and how do I solve it?
Code:
Imports System.Windows.Forms.DataGrid
Imports System.Data
Imports System.Data.SqlClient
Public Class InventoryMainForm
Private CatCodeDesc As String
Private CatCode As String
Private WarehouseLocation As String
Private Warehouse As String
Private UOMCode As String
Private subcatcode As String
Private subcat1code As String
Private subcat2code As String
Private subcat3code As String
Private AddNew As Boolean
Dim DQcheck As New SqlCommand
Dim DHcheck As New SqlDataAdapter
Dim DScheck As New DataSet
Dim Dvcheck As New DataView
InitializeComboBox()
'Declare CatCodeComboBox as combo box
Friend WithEvents CatCodeComboBox As System.Windows.Forms.ComboBox
' This method initializes the combo box in Item Category Level 1,
' adding data from the table inv_category but limiting the drop-down size
' to six rows so the combo box doesn't cover other controls when it expands.
Private Sub InitializeComboBox()
Me.CatCodeComboBox = New System.Windows.Forms.ComboBox
Dim connString As String = "server = 192.168.1.23;" + "integrated security = SSPI;" + "database = LBB"
Dim conn As New SqlConnection(connString)
Dim strSQL As String = "SELECT ict_code FROM inv_itemcategory"
Dim da As New SqlDataAdapter(strSQL, conn)
Dim ds As New DataSet
da.Fill(ds, "inv_itemcategory")
With CatCodeComboBox
.DataSource = ds.Tables("inv_itemcategory")
.DisplayMember = "ict_code"
.ValueMember = "ict_code"
.SelectedIndex = 0
End With
Me.CatCodeComboBox.Location = New System.Drawing.Point(95, 32)
Me.CatCodeComboBox.MaxDropDownItems = 5
Me.CatCodeComboBox.DropDownStyle = ComboBoxStyle.DropDown
Me.CatCodeComboBox.Name = "CatCodeComboBox"
Me.CatCodeComboBox.Size = New System.Drawing.Size(292, 21)
Me.CatCodeComboBox.TabIndex = 0
Me.Controls.Add(Me.CatCodeComboBox)
End Sub