Jump to content

[VB.NET] inserir dados na listbox


mariogx

Recommended Posts

Boas...

VB.NET 2005

Keria saber cmo introduzo os dados de um campo de uma tabela de uma base de dados numa listbox

ja fiz a conexaõ a base de dados ja criei um oledbdatadapter ja preenchi o dataset

ja indiquei listbox1.datasource = ds2...

mas falta aqui klkr coisa =(

PS. - nao liguem ao codigo da datagrid


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


        Dim da As New OleDb.OleDbDataAdapter("select ID as [Numero],Nome, email as [Correio Electrónico] from doc", ligacao)
        da.Fill(ds1)

        Dim da2 As New OleDb.OleDbDataAdapter("Select nome from ge", ligacao)
        da2.Fill(ds2)

        ListBox1.DataSource = ds2
        ListBox1.DisplayMember = "ge.nome"
        'Atribuir a tabela como source da Grid  
        DataGridView1.DataSource = ds1.Tables(0)
        'Alterar as propriedades das colunas que quiseres      
        'DataGridView1.Columns(0).HeaderText = "Texto da Coluna"
        'DataGridView1.Columns(0).ToolTipText = "Tool tip da Coluna"
        'DataGridView1.Columns(0).Width = 20 'Largura da coluna       
        'DataGridView1.Columns(1).Visible = False



        DataGridView1.AutoGenerateColumns = True







        'DataGridView1.DataSource = ds1.Tables(0)
        'DataGridView1.Columns.Insert(0, nome)
        'MsgBox(ds1.Tables(0).Columns(0))
    End Sub
Link to comment
Share on other sites

  • 2 years later...

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.