Solved

how to create a list box with multiple columns?

Posted on 2008-10-22
18
2,577 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 29

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 29

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 29

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 29

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
 
LVL 29

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 29

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 29

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 29

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

828 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