Generating tables in a visual c++ window


i am trying to generate a table in an application made in visual c++. I already tried the MFC at MSDN and cant come along with it really.

Maybe someone could give me an example how to build an 2x3 table, without opening 6 boxes- i need to do it with one.

Any suggestions?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

A table of what?
Maybe all you need is one grid

Use a List Control.  Set the view mode to Report.

This will give you a multi-column, multi-row table with just about everything built in.
most probably...
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

ZazenAuthor Commented:
I wanted to use a list control. Neither my teacher nor any of the books i have can explain to me how to format it. Any suggestions?
I also had the idea of using a multilined text control. But i cant access the second and following lines of text. Any idea of this?
Then i read about adding excel tables, but thats far beyond my knowledge of visual c++ (for now...)

The table should look something like that:

x       y  (I wanted to use CHeaderCtrl on this, but     dont know ho too)
0       10
10      20

Any new ideas?
If you insert a CListCtrl, go to the properties and change the "View" property to "Report" to use the CHeaderCtrl (as imadjinn suggested).  Then you call "InsertColumn" to insert each of your columns.  Then call InsertItem to insert the item, and SetItemText to set the text of a field.  Like if I wanted to insert two columns into a list control named m_list, it might look like:
CRect rect;
m_list.GetWindowRect(rect); // Get the list control's size so that you can make the columns the same size
// Leave a couple of pixels for the separator, which is why the "- 2" is added
m_list.InsertColumn(0, "x", LVCFMT_LEFT, rect.Width() / 2 - 2); // Insert the first column
m_list.InsertColumn(1, "y", LVCFMT_LEFT, rect.Width() / 2 - 2); // Insert the second column
m_list.InsertItem(0, "0"); // Insert the first item
m_list.SetItemText(0, 1, "10"); // Set the second column's value in the first item
m_list.InsertItem(1, "10");
m_list.SetItemText(1, 1, "20");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
this is a simple enough table to also maybe just output the text to the window directly (to the DC)

ZazenAuthor Commented:
Thank you mnashadka, dont have the time yet, but will try it tomorrow morning- hope i get it...

And thank you Dancer, but i tried that. I picked multiline in the output control, but i cant insert the second line, cause it overwrites the first. Suggestions?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.