Solved

how to create a list box with multiple columns?

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

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Install both Office 2010 and 2013 4 57
checkbox to hide entire section 10 76
Access2016 ignore hyphen in data entry or searches 5 70
Modify Text File with Excel Macro 13 50
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…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

751 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