BookmarkSubscribeSubscribe to RSS Feed
djhanson

Community Trekker

Joined:

Jun 23, 2011

Tablebox - how to underline a row?

Is there any way to underline certain row(s) within a Tablebox?

 

I'd even be happy with a graphical line drawn below the row, too.  I can color any rows of course, but would prefer a line (as a horizontal deliniation at certain points within the table).  thx, DJ

2 REPLIES
ih

Community Trekker

Joined:

Sep 30, 2016

Re: Tablebox - how to underline a row?

You could use annotations, the user can move them though:

table box with lines.PNG

 

Names default to here( 1 );

win = New Window("Text Box",
	tb = Table Box(  
		sb = String Col Box( "letter", {"a", "b"} ), 
		neb = Number Col Box( "number", { 1 ,  2 } )
	),
	<< Padding( 10 )
);

//add more rows
for( i=1, i<=10, i++, tb << Add Row( {"c", 3} ) );

//make sure table is redrawn so it has the correct size
win << redraw;
wait(0);

//Function to calculate the position of the bottom of a row within the table then
//draw a line on top of the table
AddLine = function( {tablebox, row},
	ht = tablebox << Get Height;
	w = tablebox << Get Width;
	nrows = N Items( Words( sb << Get XML, "\!N" ) ) - 2;
	
	tablebox << Add Line Annotation( 
		Line( 1, floor( row * ht / nrows ) + 1, w, floor( row * ht / nrows ) + 1 )
	);
);

//Draw some lines
AddLine( tb, 2); AddLine( tb, 8); AddLine( tb, 12 );
txnelson

Super User

Joined:

Jun 22, 2012

Re: Tablebox - how to underline a row?

Brilliant!

Jim