Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computer Certification > MCSD > Column Styles

Reply
Thread Tools

Column Styles

 
 
Rich
Guest
Posts: n/a
 
      10-02-2003
If you're talking about a Windows Control (as opposed to
Web Control), you need to instantiate a "TableStyle",
which contains a "ColumnStyles" collection. You add
members to the colection for each of the columns you want
to appear in your Grid. Once you've done that, you can
manipulate quite a few properties in both TableStyles and
the collection members for widths, fonts, colors,
borders, etc.

I hope this sample code will give you a basic model. It
uses DataGridTextBoxColumn objects, which is the
easiest. But you can derive your own classes to use as
ColumnStyles, as well.

Private Sub FillDocGrid(ByVal DocID As Integer)
OleDbSelectCommand2.CommandText=SelectDocsCmd &
DocID.ToString & "'"
DocumentsDA.Fill(TechLibDS, "Documents")

DocGrid.DataSource = TechLibDS
DocGrid.DataMember = "Documents"
Dim DocGridTS As New DataGridTableStyle()
DocGridTS.RowHeadersVisible = False
DocGridTS.MappingName = "TechLibDS.Documents"

' MappingName links DataTable columns to the
' ColumnStyles
Dim IDCS As New DataGridTextBoxColumn()
IDCS.MappingName = "ID"
IDCS.HeaderText = ""
IDCS.Width = 0
DocGridTS.GridColumnStyles.Add(IDCS)

Dim DocDateCS As New DataGridTextBoxColumn()
DocDateCS.MappingName = "DocDate"
DocDateCS.HeaderText = "Date"
DocDateCS.Width = 120
DocGridTS.GridColumnStyles.Add(DocDateCS)

Dim TitleCS As New DataGridTextBoxColumn()
TitleCS.MappingName = "Title"
TitleCS.HeaderText = "Document Title"
TitleCS.Width = 400
DocGridTS.GridColumnStyles.Add(TitleCS)

Dim DescCS As New DataGridTextBoxColumn()
DescCS.MappingName = "Description"
DescCS.HeaderText = "Document Descripition"
DescCS.Width = 800
DocGridTS.GridColumnStyles.Add(DescCS)

DocGrid.TableStyles.Clear()
DocGrid.TableStyles.Add(DocGridTS)
End Sub

HTH - there's more details in MSDN
Rich
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activa or not activate a button column depending if another data column has data or not carlos perez ASP .Net 0 06-08-2004 02:16 PM
Add column to the last column of Datagrid Hai Nguyen ASP .Net 0 01-16-2004 10:10 PM
Is there a method to fetch the last value stored in a DB column with out having to read in the entire column? DeWitt Phillips ASP .Net 2 12-12-2003 11:29 AM
How to bind a db image column (byte array) to a datagrid column? Jim Hammond ASP .Net 1 11-26-2003 12:55 AM
Templated column cannot access datasource column ASP .Net 2 11-10-2003 03:58 PM



Advertisments