|
of_setdatasource
|
|
Full name
|
pfc_u_lv.of_setdatasource
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_setdatasource(string,n_tr,string,string,string,string,string,string)
|
public function integer of_setdatasource (string as_datawindow, n_tr at_trans, string as_labelcolumn, string as_picturecolumn, string as_statecolumn, string as_overlaycolumn, string as_xposcolumn, string as_yposcolumn);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_SetDataSource
//
// Access: public
//
// Arguments:
// as_DataWindow The DataWindow object to be used for the data source.
// at_Trans The transaction object for this data source.
// as_LabelColumn The column in the DataWindow object to display as the label.
// as_PictureColumn The column in the DataWindow object to use for the picture.
// The column may be an integer (used as the picture index) or a
// string (a bmp name which will be used as the picture). Or a number
// may be passed in (i.e. "1") which will be used as the picture index
// for all items.
// as_StateColumn The column in the DataWindow object to use for the state picture.
// The column may be an integer (used as the picture index) or a
// string (a bmp name which will be used as the picture). Or a number
// may be passed in (i.e. "1") which will be used as the state picture
// index for all items.
// as_OverlayColumn The column in the DataWindow object to use for the overlay picture.
// The column may be an integer (used as the picture index) or a
// string (a bmp name which will be used as the picture). Or a number
// may be passed in (i.e. "1") which will be used as the state picture
// index for all items.
// as_XPosColumn The column in the DataWindow object to use for the x-position
// of the item (used in large icon and small icon views only).
// as_YPosColumn The column in the DataWindow object to use for the x-position
// of the item (used in large icon and small icon views only).
//
// Returns: Integer
// 1 - the data source was added successfully
// -1 - there were no key columns defined on the DataWindow
// -2 - one of the columns provided did not exist
// -3 - no DataWindow object was provided
// -4 - the SetTransObject failed
//
// Description: Register a data source for the ListView. The data source is a
// DataWindow object that will be linked to the ListView level and used
// to populate.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 5.0 Initial version
// 5.0.03 Add deletion of previous columns
// 6.0.01 Call of_settransobject on datastore rather than settransobject
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 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.
//
//////////////////////////////////////////////////////////////////////////////
If as_DataWindow = "" Then Return -3
// Create a DataStore to use as the data source
If IsNull(ids_Source) Or Not IsValid(ids_Source) Then
ids_Source = Create n_ds
ids_Source.of_SetBase(true)
End if
// Set parameters for the DataStore
ids_Source.DataObject = as_DataWindow
If ids_Source.of_SetTransObject(at_Trans) <> 1 Then Return -4
// Set data source values
is_LabelColumn = as_LabelColumn
If Trim(as_LabelColumn) <> "" And &
ids_Source.Describe(as_LabelColumn + ".Band") = "!" Then Return -2
is_PictureColumn = as_PictureColumn
If Trim(as_PictureColumn) <> "" And Not IsNumber(as_PictureColumn) And &
ids_Source.Describe(as_PictureColumn + ".Band") = "!" Then Return -2
is_StateColumn = as_StateColumn
If Trim(as_StateColumn) <> "" And Not IsNumber(as_StateColumn) And &
ids_Source.Describe(as_StateColumn + ".Band") = "!" Then Return -2
is_OverlayColumn = as_OverlayColumn
If Trim(as_OverlayColumn) <> "" And Not IsNumber(as_OverlayColumn) And &
ids_Source.Describe(as_OverlayColumn + ".Band") = "!" Then Return -2
is_XPosColumn = as_XPosColumn
If Trim(as_XPosColumn) <> "" And &
ids_Source.Describe(as_XPosColumn + ".Band") = "!" Then Return -2
is_YPosColumn = as_YPosColumn
If Trim(as_YPosColumn) <> "" And &
ids_Source.Describe(as_YPosColumn + ".Band") = "!" Then Return -2
// Add a computed column to the DataWindow object that will
// contain all the keys concatenated together. This is necessary
// to be able to find a unique row.
If of_CreateKey() = -1 Then
// No key columns were defined
Return -1
End if
// Delete the columns if already exists and clear column array
of_DeleteColumns()
// Add a column to the ListView for the Label
of_AddColumn(as_LabelColumn)
Return 1
end function