Wx::Grid

From WxPerl wiki

Revision as of 12:54, 26 June 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To create:

	use Wx::Grid;
	my $grid = Wx::Grid->new(
		$someframe, #parent
		-1, #id
		[50,100], #position
		[300, 300] #dimensions
	);
	$grid->CreateGrid(
		10, #rows
		2 #cols
	);

To add values:

	$grid->SetCellValue(
		0, #row
		0, #col
		"Hello"
	);

Cell formatting etc:

	$grid->SetReadOnly(1, 0);
	$grid->SetCellValue(1, 0, "This is read-only" );
	$grid->SetCellValue(2, 0, "coloured");
	$grid->SetCellTextColour(2, 0, Wx::Colour->new(255,0,0));
	$grid->SetCellBackgroundColour(2, 0, Wx::Colour->new(255,255,128));
	$grid->SetColFormatFloat(0, 0, 2);
	$grid->SetCellValue(3, 0, "3.1415");

Cell Row, Column Labels and sizes

	# SetColLabelSize seems to operate on the height, not very usefull.
	#$grid->SetColLabelSize(150);
	#  
	$grid->SetColLabelValue(0,"Column 0 Label Value");
	$grid->SetRowLabelSize(150);
	$grid->SetRowLabelValue(0,"Row 0 Label Value");
Google AdSense