Code for table

General TRichView support forum. Please post your questions here
Post Reply
VicFan
Posts: 11
Joined: Sun Jul 28, 2019 8:34 pm

Code for table

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Code for table

Post 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);
Post Reply