473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid TableStyle giving odd results.

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
0 877

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1553
by: Job Lot | last post by:
I have an Expense Data Entry form which contains a DataGrid showing various expense categories. There are three columns Description, Cash Exp, Credit Exp, where Description column is readonly. ...
0
1050
by: oscar | last post by:
i currently have a dataset with a built, code and description fields. the built field is either a 1 or 0 and i would like it to display as a checkbox in the datagrid. i can get the checkboxes to...
2
2485
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
2
6373
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
14
1822
by: Brett Sinclair | last post by:
Hello everybody I'm still on the learning curve here...and from what I read, I created inherited datagrid class so I could have icons, combobox...etc in the columns of my datagrid. The grid...
2
2673
by: Ron L | last post by:
I am attempting to set up a datagrid that will 1) display a subset of data from a SQL Stored Procedure in a different order form how SQL returns it, and 2) display 3 of the columns using pulldowns....
7
2024
by: Earl | last post by:
Any known fixes for the wacky right-alignment bug in the WinForms datagrid (VS2003)? I've tried Ken's workaround...
2
1156
by: Michael Kellogg | last post by:
I have a collection of objects that I am trying to display in a Windows Forms Datagrid. I have had problems doing this before, so the first time around I went and did a Grid.TableStyles.Clear...
2
1355
by: Dennis T. Holm | last post by:
HEy Im having problems with setting the width of my columns of my datagrid. Here's the code resultatGrid.DataSource = getFirms(0) // gets metaData from database Dim tableStyle As New...
4
1894
by: Jeff | last post by:
I am stuck on trying to generate two columns headers for a datagrid on form load. I can use a datatable as the datasource and get the results I want, but I want to set different column widths and...
0
7064
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
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7315
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...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
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...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4665
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
3158
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
1492
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 ...

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.