Hello,
I am getting an error when trying to update a combox. The error I get is "Object reference not set to an instance of an object". I have to click "OK" a couple of times, then the form loads and actually shows the items in the combobox. Any help is appreciated.
Thank you!!
This is in my form load event where I want to update the combobox.
Code:Dim TaxProj As New clsTaxEntity TaxProj.UpdateTaxProjectionCombobox(cmbTax)Code:Public Sub UpdateTaxProjectionCombobox(ByRef cmbX As ComboBox) Try Dim desc As New ArrayList Dim rsTax As New clsSQLData cmbX.Items.Clear() rsTax.ExecuteQuery("SELECT projection_year , tax_desc , ktax FROM tax_projection ORDER BY Projection_year") For Each drTax As DataRow In rsTax.sqlDataSet.Tables(0).Rows desc.Add(New clsComboTag(String.Format("{0} {1}", drTax("projection_year").ToString.PadRight(10), drTax("tax_desc")), drTax("ktax").ToString)) Next cmbX.DataSource = desc 'This is where I get the error cmbX.DisplayMember = "Description" cmbX.ValueMember = "Value" rsTax = Nothing Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation) End Try End SubCode:Imports System.Windows.Forms Public Class clsComboTag Private StringDesc As String Private ValueID As String Public Sub New(ByVal desc As String, ByVal value As String) Me.StringDesc = desc Me.ValueID = value End Sub Public Property Description() As String Get Return StringDesc End Get Set(ByVal value As String) StringDesc = value End Set End Property Public Property Value() As String Get Return ValueID End Get Set(ByVal value As String) ValueID = value End Set End Property End Class




Reply With Quote