Page 1 of 1

Code for table

Posted: Mon Aug 05, 2019 6:22 pm
by VicFan
I am trying to figure out code for a table and tried the following:

Code: Select all


	TRVTableItemInfo * table;

	table = new TRVTableItemInfo(1, 3, RichView1->RVData);

	table->Cells[0][0]->Clear();
	table->Cells[0][0]->AddNL("One", 1, 1);
	RichView1->AddItem("A", table);

	table->Cells[0][1]->Clear();
	table->Cells[0][1]->AddNL("Two", 1, 1);
	RichView1->AddItem("B", table);

	table->Cells[0][2]->Clear();
	table->Cells[0][2]->AddNL("Three", 1, 1);
	RichView1->AddItem("C", table);

	RichView1->Format();
But what I am getting is for every column in the table, I get that many identical rows. For example, the above gives three identical rows, since I had a 3 columns.

How do I get a table with just one row from the above pattern, or something similar?

Re: Code for table

Posted: Tue Aug 06, 2019 5:41 pm
by Sergey Tkachenko
You add the same table object 3 times (each time when you call AddItem).
As a result, you can see 3 identical tables, and a crash at exit (when TRichView tries to free this table 3 times).

Just add this table one time:

Code: Select all

       TRVTableItemInfo * table;

	table = new TRVTableItemInfo(1, 3, RichView1->RVData);

	table->Cells[0][0]->Clear();
	table->Cells[0][0]->AddNL("One", 1, 1);

	table->Cells[0][1]->Clear();
	table->Cells[0][1]->AddNL("Two", 1, 1);

	table->Cells[0][2]->Clear();
	table->Cells[0][2]->AddNL("Three", 1, 1);
	RichView1->AddItem("ABC", table);