How do I use paintCell( ) to drawtext in a table?

I want to create a table which contains three columns. I use struct to pack data and store the struct in a
vector. Now I want to present the data in a table but don’t konw how to use paintCell().
struct 2
I would appreciate it if anyone can tell me how to draw table with data from a vector or how paintCell() works.
Thanks in advance.

Paint cell will draw an iteration of however many rows are being set in the numRows variable. You will need to set up a tableLisBox and have it set up with the appropriate headers. You could use the tutorial tablelistbox and then remove the included XML file and replace the header portion to include your own headers. Then in paintcell you would work with the getattributeforcolumnID function to tell it which attributes belong in each column and to print the values from each item in the array with a for loop thing that’s based on the numrows / length of array/vector. Paintcell uses a row number variable and youd pass that in the function to iterate through your array in the case of a list box but with the listboxmodel you’ll need to indicate what data goes in each column as well.

1 Like

Ok, thank you very much.

Is this way to use the paintCell() function?

It still don’t work.

Does anyone konws what I did wrong?
Many thanks.

I’m not sure from looking into the code you posted but all the info for a basic table is in the tutorial you just have to swap out the parts that are pulling the strings out of the XML file and change them for your vector/array way of doing it. remember to update NumRows, and updateContent() on the table to see any changes reflected.

1 Like

Thank you so much. This helped me a lot.:slightly_smiling_face: