krabourn
(Hey THIS is FUN)
2002-10-26 10:33 PM
KixForms: How do you delete a column

I have been trying to remove a column from a .ListView object. Adding or clearing a column is no problem, but I can not delete it.

I have tried .Remove.

So what is the magic?

I am hoping to be able to delete a column without losing any data in the other columns or at least not the ones before it.

Thanks


Sealeopard
(KiX Master)
2002-10-26 10:54 PM
Re: KixForms: How do you delete a column

You might want to check the KiXForms documantation at http://www.kixforms.freeuk.com/documentation.htm for permitted methods.

krabourn
(Hey THIS is FUN)
2002-10-26 11:03 PM
Re: KixForms: How do you delete a column

Been there. Done that. Went through the ListView.DOC. Tried searching this site.

I was hoping someone had already tried this.


ShawnAdministrator
(KiX Supporter)
2002-10-26 11:12 PM
Re: KixForms: How do you delete a column

Deleting columns will be in the next release, but your right - the syntax will be:

$ListView.Columns(n).Remove

or

$ListView.Columns.Remove(n)

Either one works. I could release the next version tonight - not sure if Rod is around to promote to the web site though ... stay tuned.


krabourn
(Hey THIS is FUN)
2002-10-26 11:23 PM
Re: KixForms: How do you delete a column

Thanks!

Is there a way to add a bunch of items at once without looping through an array? I remember reading talk about it but I have not been able to. Is this in tonight's hopefull release?

Current example:

code:
IF Open (10, $FileComputerList, 2) = 0
$TempComputerList = ''
$LineComputerList = ReadLine (10)
WHILE @error = 0
$TempComputerList = $TempComputerList + $LineComputerList + ','
$LineComputerList = ReadLine (10)
LOOP
$RC = Close (10)
$ArrComputerList = Split (SubStr ($TempComputerList, 1, Len ($TempComputerList) - 1), ',', -1)
FOR EACH $Computer IN $ArrComputerList
$Item = $List.Items.Add
$Item.Text = $Computer
NEXT
ENDIF



ShawnAdministrator
(KiX Supporter)
2002-10-26 11:38 PM
Re: KixForms: How do you delete a column

Yeah, that isn't in there yet mostly because I haven't figured out what the correct syntax should be ... are you meaning something like what you can do with the listbox object:

$ListBox.List = 1,2,3,4,5,6

If yes, yeah - I haven't nailed down the syntax for ListView yet, maybe like

$ListView.Items = 1,2,3,4,5,6

Is this what your meaning ?

-Shawn

[ps] Just as an FYI, one might ask themselves why there are two methods for deleting columns (or items), the first example above:

$ListView.Columns.Remove(n)

asks the Columns collection to delete a particular column from its collection, the second example:

$ListView.Columns(n).Remove

asks a particular column to remove ITSELF from the collection - subtle difference but same effect.


krabourn
(Hey THIS is FUN)
2002-10-26 11:47 PM
Re: KixForms: How do you delete a column

Yes. I was not sure if was going to be from a string list or an array? How did you plan on working with multiple columns?

code:
Computer    Ping    Access
Computer1 Yes Yes
Computer2 Yes No
Computer3 No No



ShawnAdministrator
(KiX Supporter)
2002-10-26 11:53 PM
Re: KixForms: How do you delete a column

You hit the nail right on the head. Thats exactly what im trying to figure out right now, multicolumn data, was thinking about something like this. If you wanted to create an internalize version of a Kixtart table, say that contained 3 rows by two columns, could do this (define and load a two dimensional table):

dim $rows[2] ; Three rows (0-2)

$Rows[0] = "Shawn,173
$Rows[1] = "krabourn",1462
$Rows[2] = "sealeopard",336

$ListView.Items = $Rows

This would load the complete table into the ListView ... Any others thoughts/ideas/ways we can achieve this ?

[ 26. October 2002, 23:54: Message edited by: Shawn ]


krabourn
(Hey THIS is FUN)
2002-10-27 12:27 AM
Re: KixForms: How do you delete a column

How about a way to define the Column and Row count and then load the data straight into the ListView bypassing the extra array?

ShawnAdministrator
(KiX Supporter)
2002-10-27 12:37 AM
Re: KixForms: How do you delete a column

You mean like this ?

code:
 
$List.Columns.Count = 3
$List.Items.Count = 10

For Each $Item in $List.Items
$Item.Text = "krabourn"
$Item.SubItems(1).Text = "was"
$Item.SubItems(2).Text = "here"
Next

?

[ 27. October 2002, 00:38: Message edited by: Shawn ]


krabourn
(Hey THIS is FUN)
2002-10-27 04:33 AM
Re: KixForms: How do you delete a column

I don't have much experience with Multi-Dimensional arrays. The following is for a single dimension array. Creating all the items first seems to run faster than looping and creating them one by one.

I am just not sure, yet, how I am going to read a file and add the info to a multi-dimensional array, which would be the ListView. Sometimes things have to ramble in my head for a day or two.

code:
IF Open (10, $FileComputerList, 2) = 0
$TempComputerList = ''
$LineComputerList = ReadLine (10)
WHILE @error = 0
$TempComputerList = $TempComputerList + $LineComputerList + ','
$LineComputerList = ReadLine (10)
LOOP
$RC = Close (10)
$ArrComputerList = Split (SubStr ($TempComputerList, 1, Len ($TempComputerList) - 1), ',', -1)
$List.Items.Count = Val (UBound ($ArrComputerList) + 1)
FOR $Index = 0 TO Val (UBound ($ArrComputerList))
$List.Items($Index).SubItems(0).Text = $ArrComputerList[$Index]
NEXT
; FOR EACH $Computer IN $ArrComputerList
; $Item = $List.Items.Add
; $Item.Text = $Computer
; NEXT
ENDIF