?
Solved

Generating tables in a visual c++ window

Posted on 2003-02-24
7
Medium Priority
?
193 Views
Last Modified: 2010-04-01
Hi,

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?

Bye,

Jakob
0
Comment
Question by:Zazen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:Dancer
ID: 8012576
A table of what?
Maybe all you need is one grid

<><
Dancer
0
 
LVL 1

Expert Comment

by:imadjinn
ID: 8013232
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.
0
 

Expert Comment

by:Dancer
ID: 8014907
most probably...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Zazen
ID: 8015654
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?
0
 
LVL 8

Accepted Solution

by:
mnashadka earned 150 total points
ID: 8016528
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");
0
 

Expert Comment

by:Dancer
ID: 8017179
this is a simple enough table to also maybe just output the text to the window directly (to the DC)

<><
Dancer
0
 

Author Comment

by:Zazen
ID: 8018026
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?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question