Public Class Add_Material_Form

    Public Sub ComboBoxMaterialClass()
        Dim MatClassnum As Integer
        Dim MaterialClass() As String = {"Book", "Dissertation", "Journal", "Theses"}

        For MatClassnum = 0 To 3
            MaterialClass(MatClassnum) = cmbMaterialClass.Items.Add(MaterialClass(MatClassnum))
        Next

        cmbMaterialClass.Text = "Select Material Class"
    End Sub

    Private Sub Add_Material_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBoxMaterialClass()

    End Sub

End Class

Here's the code of my program.
I have 2 Forms when I go to the Form 1 the combo box bind information will be loaded, then if I go back to Form 2 then go back again to the Form 1 the combo box information will added up the same details above.
Any suggestion how to solve my problem?
Thanks in advance

Recommended Answers

All 4 Replies

you can do this by storing the data in database and everytime instead of loading data from array load from database.This will solve your problem,as when you add any data,it will be added in database and on retrieving data,you will also get newly added row.

How can I do your suggestion sir?
Can you present a code? so that I could barely understand.
Honestly,I'm a bit confuse to your answer.
But any way,thanks for your response sir.

Hi, if I get your meaning right you just have clear the combobox on formload.

Private Sub Add_Material_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cmbMaterialClass.Items.Clear()
        ComboBoxMaterialClass()
End Sub

yes sir, you're right.
thanks for the reply.
i was a little bit confuse on how to remove the redundant entries when the form loads.
it should be clear first then insert the data bound.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.