Solved

how to create a list box with multiple columns?

Posted on 2008-10-22
18
2,561 Views
Last Modified: 2013-11-26
Hi all
i need to create a list box that has multiple columns using window forms.
Please advice
thanks
0
Comment
Question by:yanggoh
  • 9
  • 8
18 Comments
 
LVL 5

Expert Comment

by:jose_juan
ID: 22774895
Hi,

the trivial solution are use a font with fixed width.

VS have not a combobox with multiple columns.

You can try to use the internal objects of Access (with multiple columns support ) but I don't known if you will can.

Propietary controls are available for it purpose you can buy it.

Also, you can make your own control. I think is a interesting exercice.

A free solution is

http://www.codeproject.com/KB/combobox/multicolumncombo.aspx

Regards.
0
 
LVL 28

Expert Comment

by:pepr
ID: 22775025
You can also use tabulation positions for the list box. However, listbox is probably not that suitable for displaying more columns. Try the ListView control.

See the attached simple application that does that through ATL + WTL. But the underlying control is the ListView.
ListView.png
listview.zip
0
 

Author Comment

by:yanggoh
ID: 22775595
Hi pepr
that is the kind of list box that i would like to have..thanks a lot
i am new to vc++...there is an error inside the cpp file

1>c:\documents and settings\cheeyang\desktop\listview\listview.cpp(7) : fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory

where do i get the file atlbase.h?
please advice
0
 
LVL 28

Expert Comment

by:pepr
ID: 22776808
Actually, I have converted some older project to the VC++ 8 one (Visual Studio 2005) -- installed the default way. In my case, the file can be found at

C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\atlbase.h

and it should be part of the standard installation. However, the converted project probably still read the file from Visual Studio .NET (older).

With VS 2005, try the newer sources.

However, you also have to download the WTL 8.0 from http://sourceforge.net/projects/wtl/ and unpack it to
C:\Program Files\Microsoft Visual Studio 8\VC\WTL80\ or modify the project.
listview.zip
0
 

Author Comment

by:yanggoh
ID: 22777044
sorry..i am using VS9.0 and inside  C:\Program Files\Microsoft Visual Studio 9.0\VC\include  does not have that file
how can i do that?
0
 
LVL 28

Expert Comment

by:pepr
ID: 22784311
OK. I have created the project for VC 9 (Visual Studio 2008). The atlbase.h is inside C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\. I have put the WTL 8 to the C:\Program Files\Microsoft Visual Studio 9.0\VC\WTL80, so the C:\Program Files\Microsoft Visual Studio 9.0\VC\WTL80\include\ was added to additional directories in the project (as $(VCInstallDir)\WTL80\include).

In the case you have the Express (free) version of the compiler, I am not sure if the ATL and MFC support is supplied. If not, I do not know if there is a legal way to get it.
ListView.zip
0
 

Author Comment

by:yanggoh
ID: 22793527
thank you for the file

1>c:\documents and settings\yang\desktop\listview\listview.cpp(7) : fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory
#include <atlbase.h>

i do not have this directory
C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\
i don't have the folder atlmfc\include\ and WTL80
0
 
LVL 28

Expert Comment

by:pepr
ID: 22793922
Do you have the free version of the Visual Studio 2008? You can get the WTL for free -- se the above link. However, it is built on top of the ATL which is part of the installation of the Visual Studio.

Of course, you can always use low level operations to work with the ListView control. The ATL are basically just C++ templates that wrap them. However, it is more work. See http://msdn.microsoft.com/en-us/library/bb774737(VS.85).aspx.

Another alternative is not to use ATL + WTL, but wxWidgets (http://www.wxwidgets.org/, http://docs.wxwidgets.org/stable/wx_wxlistview.html#wxlistview, http://docs.wxwidgets.org/stable/wx_wxlistctrl.html#wxlistctrl).
0
 

Author Comment

by:yanggoh
ID: 22830164
currently i am using the free version of visual c++ 2008. but i still do not have that file
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 28

Expert Comment

by:pepr
ID: 22830490
See the Microsoft FAQ related to Visual Studio 2008 Express (http://www.microsoft.com/express/support/faq/). The point 31

  31. Does Visual C++ 2008 Express Edition include MFC and ATL?
      No, MFC and ATL are not included with Visual C++ 2008 Express. MFC and ATL
      will be included in Visual Studio 2008 Standard and above editions.

Simply said, your free edition does not contain the ATL support. Therefore, you cannot find the atlbase.h file.
0
 

Author Comment

by:yanggoh
ID: 22830507
ic..so how do i do about the list box with multiple column without the altbase.h file?
please advice..
thanks a lot
0
 
LVL 28

Expert Comment

by:pepr
ID: 22831063
As I wrote at http:#22793922
0
 

Author Comment

by:yanggoh
ID: 22831260
hmm..any example?please
thanks
0
 

Author Comment

by:yanggoh
ID: 22887200
anyone with sample code?please share..thanks a lot
0
 
LVL 28

Expert Comment

by:pepr
ID: 22893068
Download the wxWidgets 2.8.9 from http://www.wxwidgets.org/. Install it -- you get the C:\wxWidgets-2.8.9\ (source files). Then read the C:\wxWidgets-2.8.9\docs\msw\install.txt

The sources are ready to be compiled by many compilers. This also means that they are not dependent on the proprietary ATL library. You may find the initial compilation of the wxWidgets a bit difficult (but it is documented and you will be able to do it). On the other hand, this is done only once.

Then you can find the sample C:\wxWidgets-2.8.9\samples\listbox\lboxtest.cpp plus the other files in the directory.

The wxWidgets is at least very good, freely available, open-source, mature, cross-platform product that definitely is worth to consider.
0
 
LVL 28

Accepted Solution

by:
pepr earned 500 total points
ID: 22893117
The window produced by the sample looks like the below. It demonstrates more features that you need.
ListCtrl.png
0
 

Author Comment

by:yanggoh
ID: 22894999
thanks a lot
0
 

Author Comment

by:yanggoh
ID: 22895002
trying now now..thanks thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now