473,503 Members | 5,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help im going Crazy on this one

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
5 1018
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4534
by: spoilsport | last post by:
Ive got to write a multi-function program and I'm plugging in the functions but I keep getting this error from line 40. Im new to this and cant find an answer anywhere. Sam #include...
4
1455
by: Corey Dyke | last post by:
K here's what happened. For my English project at DeVry, I had to design a website for a company of my choice. So since my dad has been after me for years to do one for him, I decided to finally...
4
4768
by: Martin Odhelius | last post by:
Hello, I have a very fustrating problems while debugging ASP.NET applications. When I am debugging and stepping thru code (with F10 or F11) Visual Studio some times suddenly just stop responding...
33
2826
by: Martin Jørgensen | last post by:
Hi, In continuation of the thread I made "perhaps a stack problem? Long calculations - strange error?", I think I now got a "stable" error, meaning that the error always seem to come here now...
6
2182
by: thomas.luce | last post by:
Okay, I have been programming for a long time, and am getting back into C after about a 4 year break from it. Below is some code that won't compile for the life of me, and it is driving me crazy!...
11
2437
by: shapper | last post by:
Hello, I am creating a centered web site with various div's inside the main (pBase) div. Somehow, I am getting a gap on the top of my browser window both in IE and Firefox. I tried...
9
6520
by: ckfan.painter | last post by:
I've run into a seemingly bizarre problem with insert() for std::vector. (This was done on Microsoft Visual C++ 2005 express version 8...maybe it is a compiler specific bug?) Here's the code: ...
0
2872
by: Teo | last post by:
Hi!! I have been trying to fix an error I keep getting on my VB.NET code. For some reason, I get an error saying "Invalid attempt to access a field before calling Read()" everytime. As you can see...
1
2655
by: shapper | last post by:
Hello, On my CMS I am signed as administrator and I am creating a Membership user and its profile: MembershipCreateStatus status; MembershipUser user = Membership.CreateUser("Joe", "Pass",...
0
7067
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.