Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2624
  • Last Modified:

how to create a list box with multiple columns?

Hi all
i need to create a list box that has multiple columns using window forms.
Please advice
thanks
0
yanggoh
Asked:
yanggoh
  • 9
  • 8
1 Solution
 
jose_juanCommented:
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
 
peprCommented:
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
 
yanggohAuthor Commented:
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
Industry Leaders: 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!

 
peprCommented:
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
 
yanggohAuthor Commented:
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
 
peprCommented:
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
 
yanggohAuthor Commented:
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
 
peprCommented:
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
 
yanggohAuthor Commented:
currently i am using the free version of visual c++ 2008. but i still do not have that file
0
 
peprCommented:
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
 
yanggohAuthor Commented:
ic..so how do i do about the list box with multiple column without the altbase.h file?
please advice..
thanks a lot
0
 
peprCommented:
As I wrote at http:#22793922
0
 
yanggohAuthor Commented:
hmm..any example?please
thanks
0
 
yanggohAuthor Commented:
anyone with sample code?please share..thanks a lot
0
 
peprCommented:
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
 
peprCommented:
The window produced by the sample looks like the below. It demonstrates more features that you need.
ListCtrl.png
0
 
yanggohAuthor Commented:
thanks a lot
0
 
yanggohAuthor Commented:
trying now now..thanks thanks
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 9
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now