Results 1 to 6 of 6

Thread: Combobox issues

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Combobox issues

    Hi, I am making a project to see al my dvd's plus their information in a windows form with ado.net.

    Now I've made a form that has the design like the picture "design.jpg". On this picture you can also see the datasources and tables I use.

    The structure of my dataset is like on this picture: "dataset.jpg"

    This is my code:
    code Code:
    1. Public Class frmDVDcollectie
    2.  
    3.     Private Sub frmDVDcollectie_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         'TODO: This line of code loads data into the 'DtsMuziekcollectie.tblCategorieen' table. You can move, or remove it, as needed.
    5.         Me.objTblCategorieenTableAdapter.Fill(Me.objDtsMuziekcollectie.tblCategorieen)
    6.         'TODO: This line of code loads data into the 'DtsMuziekcollectie.tblDVDInhoud' table. You can move, or remove it, as needed.
    7.         Me.objTblDVDInhoudTableAdapter.Fill(Me.objDtsMuziekcollectie.tblDVDInhoud)
    8.  
    9.         Vullen()
    10.  
    11.     End Sub
    12.  
    13.     Private Sub Vullen()
    14.         Dim dtvDVDInhoud As DataView
    15.  
    16.         dtvDVDInhoud = objDtsMuziekcollectie.tblDVDInhoud.DefaultView
    17.         dtvDVDInhoud.RowFilter = "CategorieID = " & cboCategorie.SelectedValue.ToString
    18.         dtvDVDInhoud.Sort = "DvdID ASC"
    19.  
    20.         objTblDVDInhoudBindingSource.DataSource = dtvDVDInhoud
    21.         Me.objTblDVDInhoudBindingSource.MoveFirst()
    22.  
    23.  
    24.     End Sub
    25.  
    26.     Private Sub cboCategorie_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCategorie.SelectedIndexChanged
    27.         If Not cboCategorie.SelectedValue Is Nothing Then
    28.             Vullen()
    29.         End If
    30.     End Sub
    31.  
    32.     Private Sub btnVorige_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVorige.Click
    33.         Me.objTblDVDInhoudBindingSource.MovePrevious()
    34.     End Sub
    35.  
    36.     Private Sub btnVolgende_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVolgende.Click
    37.         Me.objTblDVDInhoudBindingSource.MoveNext()
    38.     End Sub
    39.  
    40.     Private Sub btnEerste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEerste.Click
    41.         Me.objTblDVDInhoudBindingSource.MoveFirst()
    42.     End Sub
    43.  
    44.     Private Sub btnLaatste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLaatste.Click
    45.         Me.objTblDVDInhoudBindingSource.MoveLast()
    46.     End Sub
    47.  
    48. End Class

    The problem I have is that when I compile the project that I can perfectly change the categoriebut when I have changed the categorie, the I've selected is there twice and the categorie that is one step above the one I've selected is gone. How can I make sure that all my categories keep standing their on there place?

    Greetings
    Hash
    Attached Images Attached Images   

  2. #2
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Combobox issues

    kevin you are in a wrong section.
    All .net related goes to vb.net section.

  3. #3
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Combobox issues

    could you again state what your problem is...
    You are getting the combo populated twice?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Re: Combobox issues

    Well, When I start my program all my information goes in the right text boxes, but when I select another category in my combo box, it goes like on the picture. On this picture I have selected Horror and normally there are 5 categories in this order: Action, Comedy, Science-fiction, horror, fantasy

    Now it stands in this order: horror, comedy, science-fiction, horror, fantasy

    What is the problem?
    Attached Images Attached Images  

  5. #5
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: Combobox issues

    I belive the click event is calling the sub which is populating the combo.
    Try not to populate the combo on click event.
    Note I don't have .NET version of vb so you might have to try yourself

    what's the name of the combo used for category.
    what's code for populating the category combo.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2007
    Location
    Belgium
    Posts
    154

    Re: Combobox issues

    Categorie combo Code:
    1. Private Sub cboCategorie_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCategorie.SelectedIndexChanged
    2.         If Not cboCategorie.SelectedValue Is Nothing Then
    3.              Dim dtvDVDInhoud As DataView
    4.  
    5.              dtvDVDInhoud = objDtsMuziekcollectie.tblDVDInhoud.DefaultView
    6.              dtvDVDInhoud.RowFilter = "CategorieID = " & cboCategorie.SelectedValue.ToString
    7.              dtvDVDInhoud.Sort = "DvdID ASC"
    8.  
    9.              objTblDVDInhoudBindingSource.DataSource = dtvDVDInhoud
    10.              Me.objTblDVDInhoudBindingSource.MoveFirst()
    11.         End If
    12. End Sub
    This is the code that selects all the data of the category I have selected.

    This is the code that fills the category combo box
    Fill Code:
    1. 'TODO: This line of code loads data into the 'DtsMuziekcollectie.tblCategorieen' table. You can move, or remove it, as needed.
    2.         Me.objTblCategorieenTableAdapter.Fill(Me.objDtsMuziekcollectie.tblCategorieen)

    The dataset, datasource and datatable are all added in the design form. As you can see on the picture at the bottom. It's design.jpg that you can find in the first post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width