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

Datagrid TableStyle giving odd results.

P: n/a
Hello,

I have a datagrid which I'm populating with the result of a dataset. The
dataset only has three columns in it, and I've put together the following
code to deal with the columns. The strange thing is, I get FOUR columns
showing. I thought this was bizarre since the DS only has three columns and
the following code only deals with three columns. Any help would be great.

Thanks!
Private Sub SetTableStyle()

' Create a Grid Table Style. Map it to the "Customers" Table.

Dim aGridTableStyle As New DataGridTableStyle

aGridTableStyle.MappingName = "SerialDetail"

'

' Create GridColumnStyle objects for the grid columns

Dim aCol1 As New DataGridTextBoxColumn

Dim aCol2 As New DataGridTextBoxColumn

Dim aCol3 As New DataGridTextBoxColumn

' Hide column 1 by setting its width to 0.

With aCol1

' .MappingName = "VendorInventoryTypeID"

..MappingName = "SerialNumberID"

..Width = 0

..ReadOnly = True

End With

' Set column 2's caption, width and disable editing.

With aCol2

'.MappingName = "Description"

..MappingName = "Description"

..HeaderText = "Description"

..Width = 20

..NullText = ""

..Alignment = HorizontalAlignment.Left

..TextBox.Enabled = False

End With

' Set column 3 and 4's caption, width and enable editing.

' Since these values are optional set their Null values.

With aCol3

'.MappingName = "SerialNumber"

..MappingName = "SerialNumber"

..HeaderText = "Serial No."

..Width = 20

..Alignment = HorizontalAlignment.Center

..NullText = ""

..TextBox.Enabled = True

End With

' Add the GridColumnStyles to the DataGrid's Column Styles collection.

' Place the "ID" column (column 1) last since it is not visible.

With aGridTableStyle.GridColumnStyles

..Add(aCol2)

..Add(aCol3)

..Add(aCol1)

End With

' Add the GridColumnStyles to the aGridTableStyle.

dgSerialNumbers.TableStyles.Add(aGridTableStyle)

End Sub
Mar 16 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.