By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

Please Help im going Crazy on this one

P: n/a
Hi Group,

Im trying to Format some coloums on my Datagrid so that only 3 Coloums are
show out of the 20 in my Dataset, I just carn`t for the life of me get it to
work, i`ve looked everywhere for info but with no joy. Does anybody have any
example code links? or even better project links? here is my following Code
if anybody can help me with this please

Many thanks
Si

Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
odaContracts.Fill(dsContracts)
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapcontracts"
Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()
With aCol1
.MappingName = "ID"
.Width = 0
End With
With aCol2
.MappingName = "Contact"
.HeaderText = "Contact"
.Width = 65
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
With aCol3
.. MappingName = "Company"
.HeaderText = "Company"
.Width = 50
.Alignment = HorizontalAlignment.Center
.NullText = ""
.TextBox.Enabled = True
End With
With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
End With
dgdContracts.TableStyles.Add(aGridTableStyle)
If dsContracts.Tables(0).Rows.Count > 0 Then
With dgdContracts
.DataSource = dsContracts.Tables(0)
.Expand(-1)
.NavigateTo(0, "Contracts")
End With
End If
End Sub
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Cor
Hi Newbie,

I do not see direct errors.

Maybe I oversee it also, but some things I cannot see.
The membernames, are they in the right cases?

What I see in the code but that has nothing to do with the problem is this
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
The dataAdapter opens himself a connection when it is not open, so that one
is not necessary.
odaContracts.Fill(dsContracts)


I hope this helps a very little bit?

Cor
Nov 20 '05 #2

P: n/a
Hi,

Before you add the tablestyle to the grid you need to set its
mapping name.

With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
.MappingName = dsContracts.Tables(0).TableName
End With
Ken
---------------------
"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:O0********************@karoo.co.uk...
Hi Group,

Im trying to Format some coloums on my Datagrid so that only 3 Coloums are
show out of the 20 in my Dataset, I just carn`t for the life of me get it
to
work, i`ve looked everywhere for info but with no joy. Does anybody have
any
example code links? or even better project links? here is my following
Code
if anybody can help me with this please

Many thanks
Si

Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
odaContracts.Fill(dsContracts)
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapcontracts"
Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()
With aCol1
.MappingName = "ID"
.Width = 0
End With
With aCol2
.MappingName = "Contact"
.HeaderText = "Contact"
.Width = 65
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
With aCol3
. MappingName = "Company"
.HeaderText = "Company"
.Width = 50
.Alignment = HorizontalAlignment.Center
.NullText = ""
.TextBox.Enabled = True
End With
With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
End With
dgdContracts.TableStyles.Add(aGridTableStyle)
If dsContracts.Tables(0).Rows.Count > 0 Then
With dgdContracts
.DataSource = dsContracts.Tables(0)
.Expand(-1)
.NavigateTo(0, "Contracts")
End With
End If
End Sub

Nov 20 '05 #3

P: n/a
Thanks for your reply,
When i add:

..MappingName = dsContracts.Tables(0).TableName

I get an error saying D:\Excellence.NET\Contracts.vb(462): 'MappingName' is
not a member of 'System.Windows.Forms.GridColumnStylesCollection'.

I guess i need to add something else but i don`t know what

Thanks again for you help so far,

Ta
Si

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uh***************@TK2MSFTNGP11.phx.gbl...
Hi,

Before you add the tablestyle to the grid you need to set its
mapping name.

With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
.MappingName = dsContracts.Tables(0).TableName
End With
Ken
---------------------
"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:O0********************@karoo.co.uk...
Hi Group,

Im trying to Format some coloums on my Datagrid so that only 3 Coloums are show out of the 20 in my Dataset, I just carn`t for the life of me get it to
work, i`ve looked everywhere for info but with no joy. Does anybody have
any
example code links? or even better project links? here is my following
Code
if anybody can help me with this please

Many thanks
Si

Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open() odaContracts.Fill(dsContracts)
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapcontracts"
Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()
With aCol1
.MappingName = "ID"
.Width = 0
End With
With aCol2
.MappingName = "Contact"
.HeaderText = "Contact"
.Width = 65
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
With aCol3
. MappingName = "Company"
.HeaderText = "Company"
.Width = 50
.Alignment = HorizontalAlignment.Center
.NullText = ""
.TextBox.Enabled = True
End With
With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
End With
dgdContracts.TableStyles.Add(aGridTableStyle)
If dsContracts.Tables(0).Rows.Count > 0 Then
With dgdContracts
.DataSource = dsContracts.Tables(0)
.Expand(-1)
.NavigateTo(0, "Contracts")
End With
End If
End Sub


Nov 20 '05 #4

P: n/a
I`ve sorted it it needed aGridTableStyle.MappingName

Judt gotta get the colour working now:(

Cheers For all you help
Ta
Si

"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:-k********************@karoo.co.uk...
Thanks for your reply,
When i add:

.MappingName = dsContracts.Tables(0).TableName

I get an error saying D:\Excellence.NET\Contracts.vb(462): 'MappingName' is not a member of 'System.Windows.Forms.GridColumnStylesCollection'.

I guess i need to add something else but i don`t know what

Thanks again for you help so far,

Ta
Si

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uh***************@TK2MSFTNGP11.phx.gbl...
Hi,

Before you add the tablestyle to the grid you need to set its
mapping name.

With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
.MappingName = dsContracts.Tables(0).TableName
End With
Ken
---------------------
"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:O0********************@karoo.co.uk...
Hi Group,

Im trying to Format some coloums on my Datagrid so that only 3 Coloums are show out of the 20 in my Dataset, I just carn`t for the life of me get it to
work, i`ve looked everywhere for info but with no joy. Does anybody have any
example code links? or even better project links? here is my following
Code
if anybody can help me with this please

Many thanks
Si

Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open() odaContracts.Fill(dsContracts)
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapcontracts"
Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()
With aCol1
.MappingName = "ID"
.Width = 0
End With
With aCol2
.MappingName = "Contact"
.HeaderText = "Contact"
.Width = 65
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
With aCol3
. MappingName = "Company"
.HeaderText = "Company"
.Width = 50
.Alignment = HorizontalAlignment.Center
.NullText = ""
.TextBox.Enabled = True
End With
With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
End With
dgdContracts.TableStyles.Add(aGridTableStyle)
If dsContracts.Tables(0).Rows.Count > 0 Then
With dgdContracts
.DataSource = dsContracts.Tables(0)
.Expand(-1)
.NavigateTo(0, "Contracts")
End With
End If
End Sub



Nov 20 '05 #5

P: n/a
better than col.width = 0

table.Columns(xxxx).ColumnMapping = MappingType.Hidden
Dominique

"Newbie!" <s_************@yahoo.co.uk> wrote in message
news:O0********************@karoo.co.uk...
Hi Group,

Im trying to Format some coloums on my Datagrid so that only 3 Coloums are
show out of the 20 in my Dataset, I just carn`t for the life of me get it to work, i`ve looked everywhere for info but with no joy. Does anybody have any example code links? or even better project links? here is my following Code if anybody can help me with this please

Many thanks
Si

Private Sub frmContracts_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If odcContracts.State <> ConnectionState.Open Then odcContracts.Open()
odaContracts.Fill(dsContracts)
Dim aGridTableStyle As New DataGridTableStyle()
aGridTableStyle.MappingName = "mapcontracts"
Dim aCol1 As New DataGridTextBoxColumn()
Dim aCol2 As New DataGridTextBoxColumn()
Dim aCol3 As New DataGridTextBoxColumn()
With aCol1
.MappingName = "ID"
.Width = 0
End With
With aCol2
.MappingName = "Contact"
.HeaderText = "Contact"
.Width = 65
.Alignment = HorizontalAlignment.Left
.TextBox.Enabled = False
End With
With aCol3
. MappingName = "Company"
.HeaderText = "Company"
.Width = 50
.Alignment = HorizontalAlignment.Center
.NullText = ""
.TextBox.Enabled = True
End With
With aGridTableStyle.GridColumnStyles
.Add(aCol1)
.Add(aCol2)
.Add(aCol3)
End With
dgdContracts.TableStyles.Add(aGridTableStyle)
If dsContracts.Tables(0).Rows.Count > 0 Then
With dgdContracts
.DataSource = dsContracts.Tables(0)
.Expand(-1)
.NavigateTo(0, "Contracts")
End With
End If
End Sub

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.