Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Comparing AddItem and AddListItem
Message
De
06/12/1999 10:56:48
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Comparing AddItem and AddListItem
Divers
Thread ID:
00299195
Message ID:
00299195
Vues:
52
I compared the two methods for populating a combobox. The question came up in [Visual FoxPro in general] How can I using code to add data into 2 column list box? Thread #299032.

I benchmarked the two methods using the following code, and I'd appreciate it if someone would care to confirm or correct my findings. Thanks.
*!* This is a running example of the two ways to add items to multicolumn combos WITH benchmarks.

ox = CreateObject( 'multicolumncombo' )
ox.show()
READ EVENTS
CLEAR EVENTS
**************************************************
*-- Class:        multicolumncombo (c:\development\misc\examples.vcx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   12/06/99 08:57:01 AM
*
DEFINE CLASS multicolumncombo AS form


	DoCreate = .T.
	Caption = "Form1"
	elapsed1 = 0
	elapsed2 = 0
	Name = "multicolumncombo"


	ADD OBJECT combo1 AS combobox WITH ;
		Height = 24, ;
		Left = 50, ;
		Top = 22, ;
		Width = 100, ;
		Name = "Combo1"


	ADD OBJECT combo2 AS combobox WITH ;
		Height = 24, ;
		Left = 50, ;
		Top = 79, ;
		Width = 100, ;
		Name = "Combo2"


	ADD OBJECT text1 AS textbox WITH ;
		Value = "ln1", ;
		ControlSource = "thisform.elapsed1", ;
		Height = 23, ;
		Left = 165, ;
		Top = 22, ;
		Width = 100, ;
		Name = "Text1"


	ADD OBJECT text2 AS textbox WITH ;
		Value = "ln2", ;
		ControlSource = "thisform.elapsed2", ;
		Height = 23, ;
		Left = 165, ;
		Top = 79, ;
		Width = 100, ;
		Name = "Text2"


	ADD OBJECT label1 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Using AddItem()", ;
		Height = 17, ;
		Left = 50, ;
		Top = 7, ;
		Width = 91, ;
		Name = "Label1"


	ADD OBJECT label2 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Using AddListItem", ;
		Height = 17, ;
		Left = 50, ;
		Top = 63, ;
		Width = 103, ;
		Name = "Label2"


	ADD OBJECT label3 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Elapsed Time", ;
		Height = 17, ;
		Left = 165, ;
		Top = 7, ;
		Width = 79, ;
		Name = "Label3"


	ADD OBJECT label4 AS label WITH ;
		BackStyle = 0, ;
		Caption = "Elapsed Time", ;
		Height = 17, ;
		Left = 165, ;
		Top = 63, ;
		Width = 79, ;
		Name = "Label4"


	PROCEDURE combo1.Init
		PUBLIC ln1
		LOCAL lni
		ln1 = SECONDS()
		WITH this
			.ColumnCount = 2
			.ColumnWidths = '100,100'

			FOR lni = 1 TO 1000

				.AddItem( 'Color' )
				.List( .ListCount, 2) = 'Red'

				.AddItem( 'Style' )
				.List( .ListCount, 2) = 'Dress'

				.AddItem( 'Size' )
				.List( .ListCount, 2) = 'Medium'

			NEXT lni
		ENDWITH
		ln1 = SECONDS() - ln1
		RETURN .T.
	ENDPROC


	PROCEDURE combo2.Init
		PUBLIC ln2
		LOCAL lni
		ln2 = SECONDS()
		WITH this

			.ColumnCount = 2
			.ColumnWidths = '100,100'

			FOR lni = 1 TO 1000

				.AddListItem( 'Color', .NewItemID + 1, 1 )
				.AddListItem( 'Red', .NewItemID , 2 )

				.AddListItem( 'Style', .NewItemID + 1, 1 )
				.AddListItem( 'Dress', .NewItemID , 2 )

				.AddListItem( 'Size', .NewItemID + 1, 1 )
				.AddListItem( 'Medium', .NewItemID , 2 )

			NEXT lni

		ENDWITH
		ln2 = SECONDS() - ln2
		RETURN .T.
	ENDPROC


	PROCEDURE text1.Init
		this.value = ln1
		this.refresh()
	ENDPROC


	PROCEDURE text2.Init
		this.value = ln2
		this.refresh()
	ENDPROC


ENDDEFINE
*
*-- EndDefine: multicolumncombo
**************************************************
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform