esquima Posted October 22, 2007 at 01:29 PM Report #142080 Posted October 22, 2007 at 01:29 PM 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
Asgorath Posted October 22, 2007 at 02:24 PM Report #142088 Posted October 22, 2007 at 02:24 PM 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
Tiago Salgado Posted October 22, 2007 at 02:52 PM Report #142095 Posted October 22, 2007 at 02:52 PM 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
esquima Posted October 23, 2007 at 01:39 AM Author Report #142324 Posted October 23, 2007 at 01:39 AM Tiago a tua maneira era mesmo o que eu precisava...bastante simples e eficaz 😉
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now