Jump to content

Recommended Posts

Posted

Boas..tou a carregar a minha datagridview directamente com um dataset...logo o nome das colunas sao as que tenho na minha bd...mas queria mudar o nome delas...será possivel??? isto sem fazer por binding, pq por ai da

Posted
    Dim colEmployeeId As New DataGridViewTextBoxColumn()
        colEmployeeId.DataPropertyName = "EmployeeID"
        colEmployeeId.HeaderText = "Employee ID"
        colEmployeeId.Name = "EmployeeID"
        colEmployeeId.ReadOnly = True
        ' Do not display this system internal number to the user.
        colEmployeeId.Visible = False
        dataGridView1.Columns.Add(colEmployeeId)
  Dim colLastName As New DataGridViewTextBoxColumn()
        ' Size the column width so it is wide enough to display the widest visible cell, including the header
        colLastName.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
        colLastName.DataPropertyName = "LastName"
        colLastName.HeaderText = "Surname"
        colLastName.Name = "LastName"
        colLastName.ReadOnly = False
        dataGridView1.Columns.Add(colLastName)

"The Dark Side Clouds Everthing. Impossible To See The Future Is."My rig: Intel Core 2 Quad Q9450 | abit IP35P | 4G Kingston 800 Mhz | XFX GeForce 9800 GX2 1G ddr3 | 2X WD5000AAJS 500Gb Sata 2 | PSU 600W || Caixa El-Diablo | Creative XMod

Posted

Acho que a forma mais correcta de fazeres isso é passares o nome das colunas já correctas para o DataSet.

Em vez de carregares o dataset com um "SELECT cod_xpto, nome_xpto, blabla_xpto FROM xptos" podes alterar a query para:

SELECT cod_xpto as Codigo, nome_xpto as Nome, blabla_xpto as Bla FROM xptos

Cumps

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.