of_InsertItem


pfcmain.pbl   >   pfc_u_tv   >   of_InsertItem   

Full name pfc_u_tv.of_InsertItem
Access public
Extend of long
Return value long
Prototype public function long of_InsertItem(long,ref n_ds,long,string,long)

Name Datatype
No Data

Name Datatype
la_Arg Any[20]
li_Index Integer
li_NewLevel Integer
ltvi_New TreeViewItem
ltvi_Parent TreeViewItem

public function long of_InsertItem (long al_parent, ref n_ds ads_obj, long al_row, string as_position, long al_after);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  of_InsertItem
//
//	Access:  public
//
//	Arguments:
//	al_Parent					The handle of the parent TreeView item that the new item will
//									be inserted under.
//	ads_obj			The DataStore containing the data to be used for the new item.
//									This can be the same DataStore that was created for the level, or
//									another maintained by the user.  If the latter, the row will be added
//									to the level's DataStore.  Passed by reference.
//	al_Row						The row in the DataStore pointing to the data.
//	as_Position				The position under the parent where the new item will be inserted:
//									"First" - before the first child of the parent (Default)
//									"Last" - after the last child
//									"Sort" - in the sorted position based on the item's label
//									"After" - after the item with handle al_After
//	al_After						The handle to the item after which the new item will be inserted.
//									Ignored unless as_Position = "After".
//
//	Returns:		Long
//					Returns the handle of the item if it was added successfully, -1 if an error occurrs.
//
//	Description:	Add a new item to the TreeView using data from a DataStore.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	5.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer				li_NewLevel, li_Index
Any					la_Arg[20]
TreeViewItem		ltvi_Parent, ltvi_New

If al_Parent <> 0 Then
	If GetItem(al_Parent, ltvi_Parent) = -1 Then Return -1
	li_NewLevel = ltvi_Parent.Level + 1
Else
	li_NewLevel = 1
End If

// Get index into the data source array
li_Index = UpperBound(inv_ds)
If li_NewLevel <= li_Index Then
	li_Index = li_NewLevel
Else
	// If new item is being added to a level > li_Index then
	// inv_ds[li_Index] must be recursive
	If Not inv_ds[li_Index].b_Recursive Then Return -1
End If

// Check if the DataStore passed is the same as the one for the level
If ads_obj <> inv_ds[li_Index].ds_obj Then
	// Verify that the it is valid for the level
	If ads_obj.DataObject <> inv_ds[li_Index].ds_obj.DataObject Then Return -1

	// Append the rows to the level's DataStore
	ads_obj.RowsCopy(al_Row, al_Row, Primary!, inv_ds[li_Index].ds_obj, 999999, Primary!)
End If

 // Set the item's data
If of_SetItemAttributes(li_index, ads_obj, al_Row, ltvi_New) = -1 Then Return -1
	
If li_Index > li_NewLevel Or inv_ds[li_Index].b_Recursive Then
	ltvi_New.Children = True
Else
	ltvi_New.Children = False
End if

//  Add the Item
Choose Case Lower(as_Position)
	Case "last"
		Return InsertItemLast(al_Parent, ltvi_New)
	Case "sort"
		Return InsertItemSort(al_Parent, ltvi_New)
	Case "after"
		Return InsertItem(al_Parent, al_After, ltvi_New)
	Case Else	// "first"
		Return InsertItemFirst(al_Parent, ltvi_New)
End Choose

end function

     
Name Owner
pfc_u_tv.of_InsertItem pfc_u_tv
pfc_u_tv.of_InsertItem pfc_u_tv

     
Name Owner
treeview.getitem treeview
treeview.insertitem treeview
treeview.insertitemfirst treeview
treeview.insertitemlast treeview
treeview.insertitemsort treeview
datastore.rowscopy datastore
systemfunctions.lower systemfunctions
systemfunctions.upperbound systemfunctions
pfc_u_tv.of_setitemattributes pfc_u_tv

     
Full name
No Data

     
Name Scope
No Data