FoxPro/Visual FoxPro - ayuda por favor list y text

 
Vista:
Imágen de perfil de CARLOS

ayuda por favor list y text

Publicado por CARLOS (8 intervenciones) el 05/02/2017 04:28:49
tengo una list con dos columna, se llama list2, tambien tengo tres cuadro de texto el text1 el text2 y el text3 quiero que los datos del text1 pase a la columna 1 de la list1 y los datos de text2 pase a colomna2 de list2, y que se sumen todos los valores de list 2 el cuadro text3, por favor ayudenme,
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Leonardo Daniel A.
Val: 1.115
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

ayuda por favor list y text

Publicado por Leonardo Daniel A. (497 intervenciones) el 05/02/2017 05:55:21
hola de momento no tengo vfox instalado...

agregar datos a un listbox

thisform.List1.AddListItem("Leonardo",1,1) && fila 1 , columna 1
thisform.List1.AddListItem(40,1,2) && misma fila 1 , columna 2 (tengo 40 años, es mi edad )

asi agregas datos a las columnas por medio de programacion



Si queremos conocer el valor de la columna 2 del listbox:


Thisform.List1.List(Thisform.List1.ListIndex, 2) && use listindex y saca el valor seleccionado, si quieres una posicion especifica pones el numero de fila... o haces un for para ir obteniendo el valor, si lo quiers sumar, pondrias una variable en 0 y luego leer cada linea e irle sumando y al final un thisform.textbox10.value = miSuma

suma = 0
For i=1 To Thisform.ListBox1.ListCount

valor = Thisform.ListBox1.List( i, 2 ) && Columna 1

suma = suma + val( valor )

Next

thisform.textbox10.value = Suma


Espero que te sirva de algo esos tips
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
sin imagen de perfil
Val: 1.011
Oro
Ha mantenido su posición en FoxPro/Visual FoxPro (en relación al último mes)
Gráfica de FoxPro/Visual FoxPro

ayuda por favor list y text

Publicado por Fidel José (657 intervenciones) el 05/02/2017 13:45:13
Te resultará mucho más fácil (y re adaptable por si quieres reemplazar el Listbox por un grid) si utilizas un cursor.
En el ejemplo que sigue, tenemos un Container con un textbox (texto) y 2 textbox numéricos (Value=0), el segundo de los cuales e usa solo para mostrar la suma, por lo que es enabled = .F.

El doble click sobre el Listbox se utiliza para editar y modificar los valores ingresados. Para saber si en el cursor se agregan o modifican valores, se utiliza la propiedad agregada al Container de nombre "Accion"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
*!*      Descripción de los objetos
*!*
*!*		ADD OBJECT 'Cnt_gen4' AS container WITH ;
*!*			BackStyle = 1, ;
*!*			Height = 215, ;
*!*			Left = 288, ;
*!*			Name = "Cnt_gen4", ;
*!*			TabIndex = 27, ;
*!*			Top = 164, ;
*!*			Width = 326
 
*!*		ADD OBJECT 'Cnt_gen4.Txt_texto1' AS textbox WITH ;
*!*			Height = 21, ;
*!*			Left = 13, ;
*!*			Name = "Txt_texto1", ;
*!*			TabIndex = 1, ;
*!*			Top = 43, ;
*!*			Width = 202
 
*!*		ADD OBJECT 'Cnt_gen4.Txt_num1' AS textbox WITH ;
*!*			Height = 21, ;
*!*			Left = 214, ;
*!*			Name = "Txt_num1", ;
*!*			TabIndex = 2, ;
*!*			Top = 43, ;
*!*			Value = 0, ;
*!*			Width = 103
 
*!*		ADD OBJECT 'Cnt_gen4.Lst_list1' AS listbox WITH ;
*!*			ColumnCount = 2, ;
*!*			ColumnWidths = "200", ;
*!*			Height = 122, ;
*!*			Left = 11, ;
*!*			Name = "Lst_list1", ;
*!*			TabIndex = 3, ;
*!*			Top = 63, ;
*!*			Width = 308
 
*!*		ADD OBJECT 'Cnt_gen4.Txt_num2' AS Textbox WITH ;
*!*			Enabled = .F., ;
*!*			Left = 231, ;
*!*			Name = "Txt_num2", ;
*!*			TabIndex = 4, ;
*!*			Top = 185, ;
*!*			Value = 0
 
*!*  Codigo de los objetos
 
 
	PROCEDURE Cnt_gen4.Init
		CREATE CURSOR curList ("texto" c(40), "valor" n(12,2))
		this.lst_list1.RowSourceType= 2
		this.lst_list1.RowSource="Curlist.texto,valor"
		ADDPROPERTY(this,"Accion",0)
		*!*	Propiedad accion
		*!*	0 - Nada
		*!*	1 - Inserta REgistro
		*!*	2 - Modifica Registro actual
 
 
	ENDPROC
 
	PROCEDURE Cnt_gen4.Lst_list1.DblClick
		WITH this.Parent
			.txt_num1.Value = curList.Valor
			.txt_texto1.Value = TRIM(curList.texto)
			.Accion = 2
		ENDWITH
 
 
	ENDPROC
 
	PROCEDURE Cnt_gen4.Txt_num1.LostFocus
		IF this.Parent.Accion>0
			this.Parent.ACcion = 0
			SELECT SUM(valor) FROM curList WHERE !DELETED() INTO ARRAY laSum
			IF _tally > 0
				this.Parent.txt_num2.Value = laSum[1,1]
			ENDIF
			this.Parent.txt_texto1.SetFocus()
		ENDIF
 
	ENDPROC
 
	PROCEDURE Cnt_gen4.Txt_num1.Valid
		IF !EMPTY(this.Value)
			IF EMPTY(this.Parent.txt_texto1.Value )
				RETURN this.Parent.txt_texto1
			ENDIF
			DO CASE
				CASE this.Parent.accion = 0
					INSERT INTO curlist (texto,valor) ;
						VALUES (ALLTRIM(this.Parent.txt_texto1.text),;
							this.Value )
				CASE this.Parent.accion = 2
					SELECT curList
					replace texto WITH ALLTRIM(this.Parent.txt_texto1.text),;
						valor WITH this.Value
			ENDCASE
			this.Parent.lst_list1.Requery
			this.Parent.txt_texto1.Value = ""
			this.Value = 0
			this.Parent.accion = 1
		ENDIF
	ENDPROC
 
	PROCEDURE Cnt_gen4.Destroy
		IF USED("curList")
			USE IN CurList
		ENDIF
 
	ENDPROC
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar