Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridColumnStyles noshow

Status
Not open for further replies.

BCrowe

Programmer
Joined
Oct 23, 2003
Messages
7
Location
US
I am using a datareader to populate a table to fill a datagrid but when I attempt to modify the datagridcolumnstyles for my datagrid I find that there are none. Below are some pertinent code snips...maybe someone can point out where I am screwing up. The data is all there and if I don't try and address the columnstyles then it displays correctly.

With m_dtInventory.Columns
.Add(New DataColumn("InventoryGUID", GetType(Guid)))
.Add(New DataColumn("Serial", GetType(String)))
.Add(New DataColumn("Category", GetType(String)))
.Add(New DataColumn("Owner", GetType(String)))
.Add(New DataColumn("Vendor", GetType(String)))
.Add(New DataColumn("Location", GetType(String)))
End With


...

Dim dgtsInventory As New DataGridTableStyle(True)
dgtsInventory.MappingName = "Inventory"

With dgInventory
.DataSource = m_dtInventory
.TableStyles.Add(dgtsInventory)
With .TableStyles("Inventory")
.GridColumnStyles(0).Width = 0
End With
End With

Any help would be appreciated,
BCrowe
 
A little clarification on my post.

As I step to the line:

.GridColumnStyles(0).Width = 0

I get an out of range error because there are no gridcolumnstyles defined. Shouldn't they be created automatically on assigning the datasource?
 
In case anyone cares, I figured out what the problem was. GridColumnStyles are not created when a datatable is set as the datasource but are when a dataview is. So all that was necessary was a single line of code to assign the datatable to a dataview and use the dataview as the datasource for the datagrid.
 
hello bCrowe,

what have you done to solve the problem? got a sample code?
 
Want a simple datagrid class?
take a look at thread796-1029632


Sweep
...if it works dont mess with it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top