#88596 - 2002-10-09 05:00 PM
Re: Kixforms - Whats the "view" on "listviews"
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
I was thinking about that too - in some of the custom grid controls i studied - they built in a function called load or import that would take a csv or xml file and import it into the sheet. But I don't know man ... the object model as it stands today is pretty powerfull and its only going to get better. Here's a script I've always wanted to write, you provide a path to a CSV file on the command line and it automatically builds a listview with column headers and everything. To use it, you just need to edit the csv file and put some header info on the first line. Hope this works for anyone that tries because im running the next maintenance build of forms (2.1.1).
You run it like this:
kix32 list.kix $filename=.\test.csv
[TEST.CSV]
code:
File,Date,Size,Version "C:\WINNT\VMMREG32.DLL","1996/10/13 21:38:00","24336","4.00" "C:\WINNT\CD32.EXE","2001/10/17 04:31:28","634087","" "C:\WINNT\CLSPACK.EXE","2001/01/12 14:04:03","49424","5.00.3802"
and the code:
code:
; ; KIXTART 4.12 ; KIXFORMS 2.1.0 ; ; Accepts a command-line parameter called $filename that specifies the ; file to use. If not specified, looks for a file called TEST.CSV in ; current directory break on ; ; usage: kix32 script [$filename="filename.csv"] ; if not $filename $filename = ".\test.csv" endif if not exist($filename) ?"$filename not found." quit endif $form = createobject("kixtart.form") $form.fontname = Verdana $form.fontsize = 8 $form.clientsize = 800,600 $list = $form.listview $list.location = 10,10 $list.width = $form.clientwidth - 20 $list.bottom = $form.clientheight - 20 if open(1,$filename) = 0 $titles = readline(1) if $titles for each $title in split($titles,",") $list.columns.add.text = $title next endif $line = readline(1) while @error = 0 if $line $item = $list.items.add $fields = split($line,",") for $i = 0 to ubound($fields) if substr($fields[$i],1,1) = '"' $fields[$i] = substr($fields[$i],2) endif if substr($fields[$i],len($fields[$i]),1) = '"' $fields[$i] = substr($fields[$i],1,len($fields[$i])-1) endif $item.subitems($i).text = $fields[$i] next endif $line = readline(1) loop if $list.items.count for each $column in $list.columns $column.width = -1 $column.width = -2 next endif $=close(1) endif $form.center $form.show while $form.visible $=execute($form.doevents) loop exit 1
[ 09. October 2002, 17:02: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#88597 - 2002-10-09 07:23 PM
Re: Kixforms - Whats the "view" on "listviews"
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
hmmm - im having second thoughts on the interface now (which i have been known to have) Maybe I didn't look far enough into the future - dont know - but would like to make the listview sort of the "center piece object" of the forms library ... down the road - have plans to implement a super listview called listgrid (something like that) that will have real cells where one can navigate around and edit them and enter data - same as excel ... plus - i would like to upgrade the LISTBOX and COMBOBOX to support these new grid methods. Scratching my head now ... maybe an interface like this would "read" better ?
Conceptualized code here:
code:
; ; KIXTART 4.12 ; KIXFORMS 2.1.0 ; break on $form = createobject("kixtart.form") $form.fontname = Verdana $form.fontsize = 8 $form.clientsize = 640,480 $list = $form.listview $list.bounds = 10,10,500,200 ; Add some columns ... $list.columns.count = 3 $list.columns.text = "Name","Address","Phone" ; Add some rows ...
$list.rows.count = 4 ; Load some data ... $list.rows(0).text = "John Doe 1", "1 Maple Street", "123-456-7890" $list.rows(1).text = "John Doe 2", "2 Maple Street", "123-456-7890" $list.rows(2).text = "John Doe 3", "3 Maple Street", "123-456-7890" $list.rows(3).text = "John Doe 4", "4 Maple Street", "123-456-7890" ; Select all the rows ... for each $row in $list.rows $row.selected = true next $form.center $form.show while $form.visible $=execute($form.doevents) loop exit 1
Its no problem to change the interface - just want to decide early (like now). [ 09. October 2002, 19:23: Message edited by: Shawn ]
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 541 anonymous users online.
|
|
|