Results 1 to 3 of 3

Thread: tablestyle

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2005
    Posts
    159

    tablestyle

    When I call formatogrid, it doesn`t work, can anybody give a hand on that
    plz
    thnx
    VB Code:
    1. Dim mitb As New DataTable("Registros")
    2.  
    3.  
    4. Private Sub frmConsultaDetalle_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.  
    6.  
    7.         LlenaLista(cboEstado, "Estado")
    8.         mitb = objTQueja.DevuelveQuejasEstado("PENDIENTE")
    9.         dtgQuejas.DataSource = mitb
    10.         formatogrid()
    11.     End Sub
    12.  
    13. Sub formatogrid()
    14.         With dtgQuejas
    15.             .BackColor = Color.GhostWhite
    16.             .BackgroundColor = Color.GhostWhite
    17.             .BorderStyle = BorderStyle.None
    18.             .CaptionBackColor = Color.FloralWhite
    19.             .CaptionFont = New Font("Tahoma", 10.0!, FontStyle.Bold)
    20.             .CaptionForeColor = Color.Black
    21.             .CaptionText = "Registros de Quejas"
    22.             .Font = New Font("Tahoma", 8.0!)
    23.             .ParentRowsBackColor = Color.Beige
    24.             .ParentRowsForeColor = Color.MidnightBlue
    25.  
    26.         End With
    27.  
    28.         Dim miestilo As New DataGridTableStyle
    29.         With miestilo
    30.             .AlternatingBackColor = Color.GhostWhite
    31.             .BackColor = Color.GhostWhite
    32.             .ForeColor = Color.MidnightBlue
    33.             .GridLineColor = Color.RoyalBlue
    34.             .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
    35.             .SelectionBackColor = Color.OldLace
    36.             .SelectionForeColor = Color.Blue
    37.             .MappingName = "Registros"
    38.         End With
    39.  
    40.         Dim grdColStyle1 As New DataGridTextBoxColumn
    41.         With grdColStyle1
    42.             .HeaderText = "Código"
    43.             .MappingName = "reclamoID"
    44.             .ReadOnly = True
    45.             .Width = 30
    46.         End With
    47.  
    48.         Dim grdColStyle2 As New DataGridTextBoxColumn
    49.         With grdColStyle2
    50.             .HeaderText = "Fecha Registro"
    51.             .MappingName = "fecRegistro"
    52.             .ReadOnly = True
    53.             .Width = 50
    54.         End With
    55.  
    56.         miestilo.GridColumnStyles.AddRange(New DataGridColumnStyle() {grdColStyle1})
    57.  
    58.         dtgQuejas.TableStyles.Add(miestilo)
    59.     End Sub

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Re: tablestyle

    Other that it needs to translated into English, it looks pretty good. Here is an example of code i use:
    VB Code:
    1. Dim grdColStyle2 As New DataGridTextBoxColumn
    2.         With grdColStyle2
    3.             .HeaderText = "File ID"
    4.             .MappingName = "FileID"
    5.         End With
    6.  
    7.         Dim grdColStyle3 As New DataGridTextBoxColumn
    8.         With grdColStyle3
    9.             .HeaderText = "DL Date"
    10.             .MappingName = "WhenDL"
    11.             .Width = 75
    12.             .ReadOnly = True
    13.         End With
    14.  
    15.         Dim grdTableStyle1 As New DataGridTableStyle
    16.         With grdTableStyle1
    17.             .AlternatingBackColor = Color.GhostWhite
    18.             .BackColor = Color.GhostWhite
    19.             .ForeColor = Color.MidnightBlue
    20.             .GridLineColor = Color.RoyalBlue
    21.             .HeaderBackColor = Color.MidnightBlue
    22.             .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
    23.             .HeaderForeColor = Color.Lavender
    24.             .SelectionBackColor = Color.Teal
    25.             .SelectionForeColor = Color.PaleGreen
    26.             'LOOK: Do not forget to set the MappingName property. Without this, the DataGridTableStyle properties
    27.             'and any associated DataGridColumnStyle objects will have no effect.
    28.             .MappingName = DS_ENTRY
    29.             .PreferredColumnWidth = 125
    30.             .PreferredRowHeight = 15
    31.         End With
    32.  
    33.         grdTableStyle1.GridColumnStyles.AddRange(New DataGridColumnStyle() {grdColStyle1, grdColStyle2, grdColStyle3})
    34.         DataGrid1.TableStyles.Add(grdTableStyle1)
    ~Peter


  3. #3
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: tablestyle

    Quote Originally Posted by silverup
    When I call formatogrid, it doesn`t work, can anybody give a hand on that
    plz
    thnx
    VB Code:
    1. Dim mitb As New DataTable("Registros")
    2.  
    3.  
    4. Private Sub frmConsultaDetalle_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    5.  
    6.  
    7.         LlenaLista(cboEstado, "Estado")
    8.         mitb = objTQueja.DevuelveQuejasEstado("PENDIENTE")
    9.         dtgQuejas.DataSource = mitb
    10.         formatogrid()
    11.     End Sub
    12.  
    13. Sub formatogrid()
    14.         With dtgQuejas
    15.             .BackColor = Color.GhostWhite
    16.             .BackgroundColor = Color.GhostWhite
    17.             .BorderStyle = BorderStyle.None
    18.             .CaptionBackColor = Color.FloralWhite
    19.             .CaptionFont = New Font("Tahoma", 10.0!, FontStyle.Bold)
    20.             .CaptionForeColor = Color.Black
    21.             .CaptionText = "Registros de Quejas"
    22.             .Font = New Font("Tahoma", 8.0!)
    23.             .ParentRowsBackColor = Color.Beige
    24.             .ParentRowsForeColor = Color.MidnightBlue
    25.  
    26.         End With
    27.  
    28.         Dim miestilo As New DataGridTableStyle
    29.         With miestilo
    30.             .AlternatingBackColor = Color.GhostWhite
    31.             .BackColor = Color.GhostWhite
    32.             .ForeColor = Color.MidnightBlue
    33.             .GridLineColor = Color.RoyalBlue
    34.             .HeaderFont = New Font("Tahoma", 8.0!, FontStyle.Bold)
    35.             .SelectionBackColor = Color.OldLace
    36.             .SelectionForeColor = Color.Blue
    37.             .MappingName = "Registros"
    38.         End With
    39.  
    40.         Dim grdColStyle1 As New DataGridTextBoxColumn
    41.         With grdColStyle1
    42.             .HeaderText = "Código"
    43.             .MappingName = "reclamoID"
    44.             .ReadOnly = True
    45.             .Width = 30
    46.         End With
    47.  
    48.         Dim grdColStyle2 As New DataGridTextBoxColumn
    49.         With grdColStyle2
    50.             .HeaderText = "Fecha Registro"
    51.             .MappingName = "fecRegistro"
    52.             .ReadOnly = True
    53.             .Width = 50
    54.         End With
    55.  
    56.         miestilo.GridColumnStyles.AddRange(New DataGridColumnStyle() {grdColStyle1})
    57.  
    58.         dtgQuejas.TableStyles.Add(miestilo)
    59.     End Sub

    Be sure that the string you provide in mappingname should be the same column name of your datatable and you didn't add the second datagridtextboxcolumn(grdColStyle2)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width