Re: Can I assign a style to a GridBox row?
- To: mathgroup at smc.vnet.net
- Subject: [mg63444] Re: Can I assign a style to a GridBox row?
- From: "Norbert Marxer" <marxer at mec.li>
- Date: Sat, 31 Dec 2005 06:40:48 -0500 (EST)
- References: <dp06bc$ge5$1@smc.vnet.net><dp2oh3$8qs$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Steven and Brian
If you prefer that the whole background of the cell has the same color
and not just the background of the text you can proceed in the
following way.
As an example I use the same data as Brian in his post (30 december
2005).
data={{Unknown Origin, 58, 100.}, {Sweden, 81, 1.23457}, {Scotland,
1826,
1.09529}, {Great Britain, 221, 0.904977}, {Netherlands, 117, 0.854701},
{Ireland, 1915, 0.626632}, {Spain, 165, 0.606061}, {Germany, 1064,
0.56391}, {England, 4349, 0.436882}, {France, 271, 0.369004}, {United
Kingdom, 889, 0.224972}} /.{x_,y_Integer,
z_Real}->{x,y,NumberForm[z,{3,4}]} ;
Step 1: Modify Brian's tableRow command in the following way: wrap
ButtonBox around StyleBox and move the option Background to the
ButtonBox command:
tableRow[data_List] := {ButtonBox[StyleBox[GridBox[{data}, ColumnWidths
-> 10, ColumnAlignments -> {Left, Center, Center}]],Background ->
If[OddQ[ i], GrayLevel[0.8], GrayLevel[0.5]]]} ;
Step 2: Modify Brian's arguments in the DisplayForm command: eliminate
FrameBox, insert the options (RowSpacings, GridFrame, GridFrameMargins)
as given below:
DisplayForm[GridBox[Table[tableRow[data[[i]]], { i, 1,
Length[data]}],RowSpacings-> 0,GridFrame->True,
GridFrameMargins->{{0,0},{0,0}}]]
With these modifications the table looks good (at least with
Mathematica 5.2 in the Windows version).
Of course you can play around with different colors (for the text and
the background) and other options (spacings).
Best regards
Norbert Marxer
www.mec.li