# TableListBox problem

**URL:** <https://forum.juce.com/t/tablelistbox-problem/12300>\
**Category:** General JUCE discussion\
**Created:** [February 1, 2014, 8:34pm UTC](https://forum.juce.com/t/tablelistbox-problem/12300 "2014-02-01T20:34:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pvaz](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pvaz](https://forum.juce.com/u/pvaz)\
**Post date:** [February 1, 2014, 8:34pm UTC](https://forum.juce.com/t/tablelistbox-problem/12300/1 "2014-02-01T20:34:47Z")

</div>

Hi,

I'm trying to use a table in my app and cannot make it work.

I'm declaring this way:

```
TableListBox table;

addAndMakeVisible(table);
table.setModel(this);
table.setColour(ListBox::outlineColourId, Colours::grey);
table.setOutlineThickness(1);
table.getHeader().addColumn("Qty", 1, 3, 3, 10, TableHeaderComponent::defaultFlags);
table.getHeader().addColumn("Description", 2, 30, 30, 100, TableHeaderComponent::defaultFlags);
table.getHeader().addColumn("Total", 3, 8, 8, 12, TableHeaderComponent::defaultFlags);
table.getHeader().setSortColumnId(1, false);

table.getHeader().setStretchToFitActive(true);
table.setMultipleSelectionEnabled(false);
```

but it stops giving me a problem with upperLimit.

Can anyone explain me why this is happening and give me one example on how to work with tables and insert data on them ?

Thanks,

Paulo

---

<div class="post-metadata">

**Author:** ![pvaz](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pvaz](https://forum.juce.com/u/pvaz)\
**Post date:** [February 1, 2014, 9:56pm UTC](https://forum.juce.com/t/tablelistbox-problem/12300/2 "2014-02-01T21:56:49Z")

</div>

Seems that i have to set the variable numRows to zero.

&nbsp;

How can i add rows to this table ?

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [February 2, 2014, 12:04am UTC](https://forum.juce.com/t/tablelistbox-problem/12300/3 "2014-02-02T00:04:07Z")

</div>

You set it in&nbsp;TableListBoxModel::getNumRows()

http://www.juce.com/api/classTableListBoxModel.html#ae7ff7c6523e8113ff1c13b39f7144bf2

It's pure so you must be overriding it already. Just return the number of rows you want.&nbsp;

---

<div class="post-metadata">

**Author:** ![pvaz](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pvaz](https://forum.juce.com/u/pvaz)\
**Post date:** [February 2, 2014, 12:16am UTC](https://forum.juce.com/t/tablelistbox-problem/12300/4 "2014-02-02T00:16:54Z")

</div>

Hi Rory,

&nbsp;

yes, already overriding getNumRows, but honestly, cannot understand the method to add the row data on my table.

&nbsp;

Basicly, i have 3 columns and i want to be able to addRow("Column1 data", "Column2 data", "Column3 data") to my table.

And also be able to update a row and/or delete it.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [February 2, 2014, 11:34am UTC](https://forum.juce.com/t/tablelistbox-problem/12300/5 "2014-02-02T11:34:32Z")

</div>

I've not used this class much but as far as I remember, you set the number of rows you want, then you call update content. That will in turn call&nbsp;refreshComponentForRow() on each cell. You override that method to do the drawing for each row. I think there is an examples in the Juce Demo that might help.&nbsp;

---

<div class="post-metadata">

**Author:** ![pvaz](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pvaz](https://forum.juce.com/u/pvaz)\
**Post date:** [February 2, 2014, 10:12pm UTC](https://forum.juce.com/t/tablelistbox-problem/12300/6 "2014-02-02T22:12:00Z")

</div>

Hi Rory,

I've made some progress to understand the concept and how to use it.

Now my only trouble is on how can i make a 2D array.

I know that i can create one 2D array simply doing String myArray[10][10], but i do not want to limit the size of my array, since i need less or more data.

How can I use a OwnedArray to be 2 dimensions and how to use it ?

I need to create one array that can be used like this:

my2DArray[0][1] = "something";

my2DArray[0][2] = "something";

my2DArray[0][3] = "something";

...

my2DArray[n][3] = "something";

&nbsp;

And also how to know the size of my array.

And finally, when i update or add anything to my arry, i cannot find the way to refresh the table.

Thanks

&nbsp;

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [February 3, 2014, 8:56am UTC](https://forum.juce.com/t/tablelistbox-problem/12300/7 "2014-02-03T08:56:52Z")

</div>

To refresh the table just updateContent(). Have you tried looking at the StringArray class? It's simple to add a remove strings from it, as well as query its size.&nbsp;&nbsp;
