?
Solved

how to create a list box with multiple columns?

Posted on 2008-10-22
18
Medium Priority
?
2,607 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
[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
  • 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
What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

 
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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

719 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