Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grade com alinhamento numérico a esquerda.
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00632104
Message ID:
00633313
Views:
19
This message has been marked as a message which has helped to the initial question of the thread.
Ok. Vendo o exemplo dá pra achar uma explicação:

Quando você coloca o "colunmcount=4" e o recordSource="mycursor" o objeto grid, como ainda não tem definido o "controlsource" de cada coluna, inclui automaticamente as colunas do mycursor. Como a 4a coluna é caracter, todas as propriedades são marcadas para este tipo de dados. Só após ele fazer todos estes processamentos, é que você explicitamente muda o tipo de dados em "Controlsource" na colunm4.

Para corrigir este problema execute assim:
LOCAL loForm as Form 

If MessageBox("Adicionar um campo caracter a MyTable?"+Chr(13)+;
			  "Somente se você responder SIM o problema acontece!"+Chr(13)+Chr(13)+Chr(13)+;
			  "Add a character field in MyTable?"+Chr(13)+;
			  "Just if you anwser YES the problem happens"+Chr(13)+Chr(13)+Chr(13),292,"BUG?") = 6
	Set Safety Off
	Create Table MyTable (Field1 N (4), Field2 N (6,2), Field3 N (12,2), Field4 C (10) )
	Set Safety On
	Insert Into MyTable (Field1, Field2, Field3, Field4) Values (1234, 12.52, 162.35, "RECNO 01")
	Insert Into MyTable (Field1, Field2, Field3, Field4) Values (2563,  2.24, 62.35, "RECNO 02")
	Insert Into MyTable (Field1, Field2, Field3, Field4) Values (8542, 36.79, 912.41, "RECNO 03")
	Insert Into MyTable (Field1, Field2, Field3, Field4) Values (9124, 58.22, 24.35, "RECNO 04")
	Insert Into MyTable (Field1, Field2, Field3, Field4) Values (9674, 33.28, 152.49, "RECNO 05")
Else
	Set Safety Off
	Create Table MyTable (Field1 N (4), Field2 N (6,2), Field3 N (12,2))
	Set Safety On
	Insert Into MyTable (Field1, Field2, Field3) Values (1234, 12.52, 162.35)
	Insert Into MyTable (Field1, Field2, Field3) Values (2563,  2.24, 62.35)
	Insert Into MyTable (Field1, Field2, Field3) Values (8542, 36.79, 912.41)
	Insert Into MyTable (Field1, Field2, Field3) Values (9124, 58.22, 24.35)
	Insert Into MyTable (Field1, Field2, Field3) Values (9674, 33.28, 152.49)
EndIf

loForm = CREATEOBJECT("Form")
loForm.Width = 700
loForm.AddObject("Grade","Grid")
With loForm.Grade
	.Width = 650
	.Visible = .T.
	.RecordSource = ""
	Set Safety Off
	Select * From MyTable Into Table MyCursor
	Set Safety On
	.RecordSource = "MyCursor"
	.ColumnCount = 3  && MARQUE AQUI APENAS AS 3 PRIMEIRAS
	With .Column1
		.ControlSource		= "Field1"
		.InputMask		= "9,999"
		.Width			= 100
		.Header1.caption	= "1"
	EndWith
	With .Column2
		.ControlSource		= "Field2"
		.InputMask		= "999.99"
		.Width			= 100
		.Header1.caption	= "2"
	EndWith
	With .Column3
		.ControlSource		= "Field3"
		.InputMask		= "999,999,999.99"
		.Width			= 100
		.Header1.caption	= "3"
	EndWith
EndWith
&& DEPOIS QUE CRIOU AS PRIMEIRAS, AS DEMAIS NÃO SÃO REGISTRADAS AUTOMATICAMENTE
loForm.grade.ColumnCount = 4
With loForm.Grade.column4
		.ControlSource		= "Round(Field2 * Field3,2)"
		.InputMask		= "999,999,999.99"
		.Width			= 100
		.Header1.caption	= "4"
endwith	
loForm.Show(1)
Se desejar fazer isso com todas, teria que deixar o "columncount=-1" e ir incrementando e formatando as columns conforme sua necessidade.
Cordialmente,

Fabiano Costa
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform