Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADEL() in array
Message
De
27/08/2001 16:50:31
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00549522
Message ID:
00549628
Vues:
17
This message has been marked as the solution to the initial question of the thread.
>>>>>>
>>>>>>Tim,
>>>>>>When you delete an array item, the entire row (unless you specify the column) is moved to the bottom of the array and given .F. values across the board. Simply re-dimension it using the current number of rows - 1 and the currnt number of columns.
>>>>>>
>>>>>>Ex.
>>>>>>Adel(MyArray,nElement)
>>>>>>lnlength = alen(MyArray,1)
>>>>>>dimension MyArray(lnlength-1,alen(MyArray,2))
>>>>>>
>>>>>>You can also surround this stuff with THISFORM.LockScreen = .T./THISFORM.LockScreen = .F. if you get too much flickering.
>>>>>>
>>>>>>HTH.
>>>>>Ok, I got your concept and executed. my array was 10 items, 7 cols.
>>>>>I deleted 1 item using adel and redimensioned it using your code( 1 less row, same # of columns) Now the listbox has scores of .F. on the bottom 30 rows :(
>>>>
>>>>PMFJI,
>>>>
>>>>Try :
>>>>
List1.Rowsource=""
>>>>dimension MyArray(lnlength-1,alen(MyArray,2))
>>>>List1.Rowsource="MyArray"
>>>>HTH
>>>I guess the trouble is when I do the ascan(10 rows, 7 cols) for a seach on fname. SQL= "select fname,lname,b3,b4,b5,b6,b7 into array z_array). I locate the lname "m.pos = ASCAN(THISFORM.MYLISTBOX1.z_array,m.fname)"
>>>m.pos gives me the element # or should I be using aelement()?
>>>
>>>-TB
>>
>>You mean to locate the currently selected item in the list? You can use the ListIndex property to get the element selected, and by definition it will be the same array row to delete.
>>
>>Was that the question?
>No, If I have a 10 by 7 array- [10 rows/7 columns and in the 7th row I locate the fname I want to delete. I want that whole row to disappear.

So the trigger for deleting an item from the listbox is when the user clicks on an item from the listbox or when he clicks a form button or other control?

If it's the first case you can delete the item as follows: (this code on the Listbox_Click() event)
Local nIndex, nLen, cFName
nIndex = This.ListIndex
nLen = ALen(myArray, 1)
cFName = myArray(nIndex, 1)  && assumes fname is at the first column
Adel(myArray, nIndex) && Deletes the whole row from the listbox
This.rowsource=""
Dimension myArray(nLen - 1, ALen(myArray,2))
This.RowSource="myArray"
*-- do whatever with cFName..
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform