PDA

Click to See Complete Forum and Search --> : Listbox


Hutty
Jan 26th, 2000, 04:08 AM
I have a listbox that retrieves data in a comma delimited format. How can display the data in the listbox in a column format. Currently, all data is displayed in one column. I want to partition the listbox in a grid like fashion.

Thanks!

Gimpster
Jan 26th, 2000, 05:34 AM
As far as the columns in your listbox, I know there have been some posts on here a while ago about that, try searching for them (search button at top of page). But I think it has something to do with setting "tabs" in your listbox. Sorry I couldn't help more, but that should give you somewhere to start. :)

------------------
Ryan

MartinLiss
Jan 26th, 2000, 05:38 AM
Why not use a grid?

------------------
Marty
COGITO EGGO SUM
I think; therefore I am a waffle.

LG
Jan 26th, 2000, 06:09 AM
Hi, Hutty.

You can do it only using Tab, but it won't look nice. It's better to use Grid control or listview. But you can try.

rs.MoveFirst
Do Until rs.EOF
List1.AddItem rs.Fields(0) & vbTab & rs.Fields(1) & vbTab & rs.Fields(2)
rs.MoveNext
Loop

Larisa

Hutty
Jan 26th, 2000, 09:59 PM
Thanks guys for your responses. I didn't mentioned before that the data is not being retrieved from your conventional access database. I'm accessing one of the .dll files from our financial software using "Application Program Interface (API)".

It looks like the Grid would be my best option, but nothing happens when insert where list1 is located in code. I believe I'm not using the DBGRID function correctly. Any code on how to use the dbgrid instead of listbox in code.

Thanks!

HDR
Jan 27th, 2000, 01:09 AM
The listbox idea is very workable. By using report view with subitems you can create columns of any width.

dim clmx as columnheader
dim itmx as listitem

set clmx = listboxname.columnheaders.Add(index, key, TEXT, WIDTH, alignment, icon)
' add a column header for each column
set itmx = listboxname.listitems.add(index, key, TEXT, icon, smallIcon)
itmx.subitems(1) = nextcolumn
' add a subitem for each additional column

Good luck.

Hutty
Jan 27th, 2000, 01:19 AM
HDR,

This is what the return string looks like in the list box.

LFDIV,FY_PREMIUM.STAT_INP,833942,1600819,2479545,653
LFDIV,REN_PREMIUM.STAT_INP,2225176,4551447,6792469,5131
LFDIV,SP_PREMIUM.STAT_INP,1765550,3273375,4654127,0
LFDIV,INW_PREM.STAT_INP,98397,186944,397835,149
LFDIV,OUTW_PREM.STAT_INP,472102,667209,863370,3088
LFDIV,RET_PREM_G.GAAP_ADJ_INP,-1615228,-3264710,-4812230,0
LFDIV,RET_PREM_G.GAAP_TL_INP,29435,148182,-68583,0
LFDIV,NIINCOME.STAT_INP,999352,2038943,2839070,585
LFDIV,NII_INC_ASSO.STAT_INP,1382,3771,7712,0
LFDIV,NII_FIN_SERV.STAT_INP,2675,4964,6493,0
LFDIV,NII_DIVELIM_DOM.STAT_INP,-40,-81,-126,0
LFDIV,NII_DIVELIM_FOR.STAT_INP,-1961,-3921,-6110,0


Is the code you provided workable as it relates to the above/

Thanks!

Buzby
Jan 27th, 2000, 11:49 AM
If you want to store stuff in a grid that isn't in a database you can a) spend hours of pain and anguish trying to use DBGRID or b) buy Apex TrueDBGrid from www.ApexSC.com (http://www.ApexSC.com) and use the XArray object which you can populate with any data you like and then bind it to a grid as if it was a database.


------------------
Mark "Buzby" Beeton
VB Developer
BuzbyB@HotMail.Com

WillP
Jan 27th, 2000, 02:24 PM
If you have a lot of data, you might want to investagate importing it into an Access table and then exporting the table to VB.

A while ago I transferred all the data from a 4th dimension database to an Access database, and the raw data looked exactly like yours.

If I remember correctly, Access had no trouble separating the comma delimited data into different fields.

Of course, this depends on the project. If you're talking about a one time deal, then the Access idea might work. If it's something your program would do all the time, then it's different.

WillP

HDR
Jan 28th, 2000, 12:52 AM
Yes, it is very workable. Do the 'clmx =' thing six times to set you columns and headers (once for each column.) Do the 'set itmx =' thing once per row. You can use an index for the row, or you can build a key (must have at least 1 alpha character.) Your data for the first column goes here. Then for the other five columns, use the 'itmx.subitems(column) =' thing.