Make visble a TableListBox


#1

Hi, I’m a newbie. I looking for a simple TableListBox. I tried using a code from “Table using for dummies” which is quite clear. In a Auxiliar.h file I define the class:

[code]class CustomGridModel : public TableListBoxModel
{
public:

CustomGridModel(void){}
~CustomGridModel(void){}

int getNumRows(void){
return 2;
}

void paintRowBackground (Graphics& g, int rowNumber, int width, int height, bool rowIsSelected){
if (rowIsSelected) g.fillAll (Colours::yellow);
else g.fillAll (Colours::lightgrey);
}

virtual void paintCell (Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected){
	g.setColour (Colours::black); 
	Font font = 12.0f; 
	g.setFont (font); 

	String text; 
	if (columnId == 1){ 
		text= String(rowNumber + 1); 
	} 

	g.drawText (text, 2, 0, width - 4, height, Justification::centredLeft, true); 
	g.setColour (Colours::black.withAlpha (0.2f)); 
	g.fillRect (width - 1, 0, 1, height); 
}

};[/code]

Then in an empty (no buttons, etc.) NewJucerComponent.h I include:

CustomGridModel *gridModel; TableListBox *table;

And in the contructor of NewJucerComponent in the NewJucerComponent.cpp file I write:

gridModel = new CustomGridModel() ; table = new TableListBox (T("TableName"),gridModel); addAndMakeVisible (table);

There is no compiling errors. However, when I execute the program I just only see an empty window. Maybe the problem is that this table has no data. I tried including

in the contructor, and I expected to see at least a header. But I still can’t see the table.

I’d thank a lot if someone tells me how to do it.


#2

Did you give the table a size and position?


#3

No, that’s the problem!

Thanks!