N
Newbie!
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
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