Problem Tablestyle

G

Guest

Hi,
i've a problem. I want hide column in datagrid.I've used tablestyle but non
display nothing.
The code is:

Dim cn As New SqlCeConnection(cs)
sqlDA = New SqlCeDataAdapter("SELECT * FROM ANAGRAFICA WHERE COGNOME
like '%" & TxtCerca.Text & "%' or NOME like '%" & TxtCerca.Text & "%'" & "
ORDER BY COGNOME ASC", cn)
sqlDS = New DataSet
sqlDA.Fill(sqlDS, "Anagrafica")
PnlCerca.Enabled = False

Dim dgts As New DataGridTableStyle
dgts.MappingName = "Anagrafica"
Dim c As New DataGridTextBoxColumn

c.MappingName = "Id"
c.HeaderText = "Id"
c.Width = 0
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Cognome"
c.HeaderText = "Cognome"
c.Width = 20
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Nome"
c.HeaderText = "Nome"
c.Width = 10
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Indirizzo"
c.HeaderText = "Indirizzo"
c.Width = 0
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Rata"
c.HeaderText = "Rata"
c.Width = 0
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Tipologia"
c.HeaderText = "Tipologia"
c.Width = 0
c.NullText = ""
dgts.GridColumnStyles.Add(c)

c = New DataGridTextBoxColumn
c.MappingName = "Camponote"
c.HeaderText = "Camponote"
c.Width = 0
c.NullText = ""
dgts.GridColumnStyles.Add(c)

GrdCerca.TableStyles.Add(dgts)
GrdCerca.DataSource = sqlDS.Tables("Anagrafica")

Can anyone help me?
 
A

Arun

Hi Raffaele,

//Add this
GrdCerca.TableStyles.Clear()

GrdCerca.TableStyles.Add(dgts)
GrdCerca.DataSource = sqlDS.Tables("Anagrafica")

Hope this helps,
Cheers,
Arun.
www.innasite.com
 
G

Guest

Arun said:
Hi Raffaele,

//Add this
GrdCerca.TableStyles.Clear()

GrdCerca.TableStyles.Add(dgts)
GrdCerca.DataSource = sqlDS.Tables("Anagrafica")

Hope this helps,
Cheers,
Arun.
www.innasite.com

The problem was Column name.... case sensitive I use for example COGNOME
and work fine.
Thank's
Raffaele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top