Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 20, 1997

Changing Colors and Fonts of DataGrid Cells

Attributes such as the foreground color, background color, and fonts of cells in Sheridan's DataGrid can easily be changed by setting RowCellxxxx properties such as RowCellForeColor, RowCellBackColor, RowCellItalic, and so on from within the RowLoaded event. This event fires when the grid initially loads records and while scrolling through rows, allowing you to set various properties for each row in the DataGrid. This code will set column 0's background color to red, text color to white, and font to italics:
 Sub SSDataGrid1_RowLoaded (BookMark As String, _ 
RowNum As Long) 
SSDataGrid1.RowCellForeColor(0) = _ 
RGB(255,255,255) 
'set foreground to white 
SSDataGrid1.RowCellBackColor(0) = RGB(255,0,0) 
'set background to red 
SSDataGrid1.RowCellItalics(0) = True 
'set font to italics 
End Sub 
Another way to change the appearance of individual cells in the DataGrid is to set the EvalRowNumber property to a specific row number and then set the appropriate RowCellxxxx properties. This illustrates this method in the Click event of a Command button:
 Sub Command1_Click() 
SSDataGrid1.EvalRowNumber = 10 
'row to be manipulated 
SSDataGrid1.RowCellForeColor(2) = _ 
RGB(255,255,255) 
'set foreground at column 2 to white 
SSDataGrid1.RowCellBackColor(2) = RGB(255,0,0) 
'set background to red 
SSDataGrid1.RowCellItalics(2) = True 
'set font to italics 
End Sub 
Sheridan Software
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date