Jump to content

Recommended Posts

Posted

eu queria saber como fazer ao escolher um item de uma combobox mostrar todos os dados correspondentes dessa combobox....mostrar os registos nas textbox desse item

Posted

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

        'TODO: This line of code loads data into the 'Clube_de_videoDataSet1.Actores' table. You can move, or remove it, as needed.

        Me.ActoresTableAdapter.Fill(Me.Clube_de_videoDataSet1.Actores)

        'TODO: This line of code loads data into the 'Clube_de_videoDataSet1.Realizadores' table. You can move, or remove it, as needed.

        Me.RealizadoresTableAdapter.Fill(Me.Clube_de_videoDataSet1.Realizadores)

        'TODO: This line of code loads data into the 'Clube_de_videoDataSet1.Filmes' table. You can move, or remove it, as needed.

        Me.FilmesTableAdapter1.Fill(Me.Clube_de_videoDataSet1.Filmes)

        Me.CategoriaComboBox.SelectedIndex = -1

        Me.CategoriaComboBox.DropDownStyle = ComboBoxStyle.DropDownList

        Dim db As New OleDbConnection(clube_de_video.My.Settings.ligacaobd)

        ' LIGAR A BD

        db.Open()

        Dim da As New OleDbDataAdapter("Select Categoria From Categoria", db)

        Dim ds As New DataSet

        da.Fill(ds, "Categoria")

        With Me.CategoriaComboBox

            .DisplayMember = "Categoria"

            .ValueMember = "Categoria"

            .DataSource = ds.Tables(0).DefaultView

            ' Definições para autocompleta

            .DropDownStyle = ComboBoxStyle.DropDown

            .AutoCompleteMode = AutoCompleteMode.Suggest

            .AutoCompleteSource = AutoCompleteSource.ListItems

        End With

    End Sub

  Private Sub CategoriaComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        If Me.CategoriaComboBox.SelectedIndex <> -1 Then

            Dim dr As DataRow = Me.Clube_de_videoDataSet.Filmes.Rows.Find(Me.CategoriaComboBox.SelectedValue)

            If dr IsNot Nothing Then

                Me.ID_FilmeTextBox.Text = dr.Item(0).ToString

                Me.ID_RealizadorComboBox.Text = dr.Item(1).ToString

                Me.ID_ActorComboBox.Text = dr.Item(2).ToString

                Me.CategoriaComboBox.Text = dr.Item(3).ToString

                Me.NomeTextBox.Text = dr.Item(4).ToString

                Me.Ano_EstreiaTextBox.Text = dr.Item(5).ToString

                Me.AutorTextBox.Text = dr.Item(6).ToString

            End If

        End If

    End Sub

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.