Column Styles

Discussion in 'MCSD' started by Rich, Oct 3, 2003.

  1. Rich

    Rich Guest

    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
     
    Rich, Oct 3, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john

    New styles lavatory?

    john, Jun 17, 2005, in forum: Computer Support
    Replies:
    3
    Views:
    451
    old jon
    Jun 17, 2005
  2. Jack

    Wedding styles

    Jack, Aug 7, 2005, in forum: Digital Photography
    Replies:
    11
    Views:
    533
    Joseph Meehan
    Aug 8, 2005
  3. Supressing Oultlne View styles

    , Jan 1, 2006, in forum: Computer Support
    Replies:
    3
    Views:
    433
    =?ISO-8859-1?Q?R=F4g=EAr?=
    Jan 1, 2006
  4. richardolives

    MORE THAN 400 STYLES OF GOOGLE SEARCH ENGINE

    richardolives, Jun 1, 2008, in forum: Digital Photography
    Replies:
    0
    Views:
    294
    richardolives
    Jun 1, 2008
  5. Lawrence D'Oliveiro

    OpenOffice.Org Styles

    Lawrence D'Oliveiro, Jan 15, 2010, in forum: NZ Computing
    Replies:
    0
    Views:
    693
    Lawrence D'Oliveiro
    Jan 15, 2010
Loading...

Share This Page