Click here to Skip to main content

Binoy R - Professional Profile

8,761
Author
15
Authority
4
Debator
10
Editor
37
Organiser
121
Participant
0
Enquirer
Binoy is a software developer of Information Technology Division in Memphis,TN.
Member since Thursday, October 23, 2003 (8 years, 7 months)

For more information on Reputation please see the FAQ.
 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
  Refresh
GeneralA routine for setting the DataGrid Style dynamically Pin
Monday, May 3, 2004 6:59 AM
~~~~~~~~~~~~~~~~~~~~
Private Sub setMyDataGridTableStyleProperties (ByRef myDG as DataGrid)
' Use a table style object to apply custom formatting
‘ to the DataGrid.
 
Dim mydgTableStyle As New DataGridTableStyle()
Dim mygrdColStyle1, mygrdColStyle2, mygrdColStyle3,
mygrdColStyle4, mygrdColStyle5 As New & _
DataGridTextBoxColumn()
 
With mydgTableStyle
.AlternatingBackColor = Color.LightCoral
.BackColor = Color.LawnGreen
.ForeColor = Color.LightGray
.GridLineColor = Color.LightGreenrodYellow
.GridLineStyle = System.Windows.Forms.DataGridLineStyle.
.HeaderBackColor = Color. LightGray
.HeaderFont = New Font("Courier", 10.0!, FontStyle.Bold)
.HeaderForeColor = Color. LawnGreen
.LinkColor = Color.Teal
 
' Do not forget to set the MappingName property.
' Without this, the DataGridTableStyle properties
' and any associated DataGridColumnStyle objects
' will have no effect.
 
.MappingName = "Customers"
 
.SelectionBackColor = Color. LawnGreen
.SelectionForeColor = Color. LightGray
End With
 
' Use column style objects to apply formatting specific
‘ to each column of customer table.
 
With mygrdColStyle1
.HeaderText = "ID#"
.MappingName = "CustomerID"
.Width = 50
End With
 
With mygrdColStyle2
.HeaderText = "Last Name"
.MappingName = "NameLast"
.Width = 140
End With
 
With mygrdColStyle3
.HeaderText = "Address"
.MappingName = "Address1"
.Width = 180
End With
 
With mygrdColStyle4
.HeaderText = "State"
.MappingName = "State"
.Width = 30
End With
 
With mygrdColStyle5
.HeaderText = "Phone"
.MappingName = "Phone"
.Width = 70
End With
 
' Add the column style objects to the tables style's
‘ column styles collection. If you fail to do this the column
‘ styles will not apply.
 
mydgTableStyle.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{ mygrdColStyle1, mygrdColStyle2,
mygrdColStyle3, mygrdColStyle4, mygrdColStyle5})
 
' Add the table style object to the DataGrid's table styles
' collection. Again, failure to add the style to the collection
' will cause the style to not take effect.

myDG.TableStyles.Add(mydgTableStyle)
 
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
You can see details on my Article 2
 
Benoy

 
Benoy
 
GeneralA routine for setting the DataGrid Style dynamically Pin
Monday, May 3, 2004 6:58 AM
Private Sub setMyDataGridTableStyleProperties (ByRef myDG as DataGrid)
' Use a table style object to apply custom formatting
‘ to the DataGrid.
 
Dim mydgTableStyle As New DataGridTableStyle()
Dim mygrdColStyle1, mygrdColStyle2, mygrdColStyle3,
mygrdColStyle4, mygrdColStyle5 As New & _
DataGridTextBoxColumn()
 
With mydgTableStyle
.AlternatingBackColor = Color.LightCoral
.BackColor = Color.LawnGreen
.ForeColor = Color.LightGray
.GridLineColor = Color.LightGreenrodYellow
.GridLineStyle = System.Windows.Forms.DataGridLineStyle.
.HeaderBackColor = Color. LightGray
.HeaderFont = New Font("Courier", 10.0!, FontStyle.Bold)
.HeaderForeColor = Color. LawnGreen
.LinkColor = Color.Teal
 
' Do not forget to set the MappingName property.
' Without this, the DataGridTableStyle properties
' and any associated DataGridColumnStyle objects
' will have no effect.
 
.MappingName = "Customers"
 
.SelectionBackColor = Color. LawnGreen
.SelectionForeColor = Color. LightGray
End With
 
' Use column style objects to apply formatting specific
‘ to each column of customer table.
 
With mygrdColStyle1
.HeaderText = "ID#"
.MappingName = "CustomerID"
.Width = 50
End With
 
With mygrdColStyle2
.HeaderText = "Last Name"
.MappingName = "NameLast"
.Width = 140
End With
 
With mygrdColStyle3
.HeaderText = "Address"
.MappingName = "Address1"
.Width = 180
End With
 
With mygrdColStyle4
.HeaderText = "State"
.MappingName = "State"
.Width = 30
End With
 
With mygrdColStyle5
.HeaderText = "Phone"
.MappingName = "Phone"
.Width = 70
End With
 
' Add the column style objects to the tables style's
‘ column styles collection. If you fail to do this the column
‘ styles will not apply.
 
mydgTableStyle.GridColumnStyles.AddRange _
(New DataGridColumnStyle() _
{ mygrdColStyle1, mygrdColStyle2,
mygrdColStyle3, mygrdColStyle4, mygrdColStyle5})
 
' Add the table style object to the DataGrid's table styles
' collection. Again, failure to add the style to the collection
' will cause the style to not take effect.

myDG.TableStyles.Add(mydgTableStyle)
 
End Sub

 
You can see more details on my article 2.
 
Benoy

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.5.120528.1 | Last Updated 28 May 2012
Copyright © CodeProject, 1999-2012
All Rights Reserved. Terms of Use
Layout: fixed | fluid