Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where can I create the cursor before grid on form initia
Message
From
18/09/2006 12:31:20
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01154646
Message ID:
01154755
Views:
20
This message has been marked as a message which has helped to the initial question of the thread.
>>Hi James
>>
>>>Have you tried bindcontrols? I have a couple of forms that worked for me. I set bindcontrols=.f. and then when I have my data environment setup I set it to .t..
>>
>>Bingo!!! That solved the problem, I am surprised Sergey and Borislav could not come up with this, maybe I was not able to explain better to them *vbg*
>
>Is it a form's property? Would it affect all other controls as well?

Yes.

If yes, what effect will later binding cause for other controls?
>

every ControlSource,RowSource,RecordSource has two faces:
a VFP face ( the property string value )
a C++ face ( the object internal structure )

Effect: while BindControl = .F., VFP don't try to eval
ControlSource,RowSource,RecordSource strings
( except for some special cases )

Then, every assign have not effect ( no errors, the C++ face still old )
when you set it to .T., VFP load all these properties ( in the whole form ).

This example show it,
- run
- refresh Button1 ( show the Combo1 rowsource )
- open combo lists
- press swap
- open combo lists
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


DEFINE CLASS form1 AS form


	BindControls = .F.

	ADD OBJECT combo1 AS combobox WITH ;
		RowSourceType = 5, ;
		RowSource = "thisform.ax", ;	&& WHEN THE FORM START, "ax" don't exist
		Height = 24, ;
		Left = 161, ;
		Top = 30, ;
		Width = 100, ;
		Name = "Combo1"


	ADD OBJECT combo2 AS combobox WITH ;
		RowSourceType = 5, ;
		Height = 24, ;
		Left = 162, ;
		Top = 74, ;
		Width = 100, ;
		Name = "Combo2"

	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 30, ;
		Left = 69, ;
		Height = 27, ;
		Width = 84, ;
		Caption = this.Combo1.RowSource, ;
		Name = "Command1"
		
	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 74, ;
		Left = 69, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "swap", ;
		Name = "Command2"
		
	PROCEDURE Init
		ADDPROPERTY(this,"ax[10]")
		&& bind Combo1
		thisform.BindControls=.T.

		* stop bind new source
		thisform.BindControls = .F.

		* every set to 
		this.Combo2.RowSource = this.Combo1.RowSource

		* this don't unbind Combo1
		this.Combo1.RowSource = ""  && this respect BindControls
	ENDPROC

	PROCEDURE command1.Click
		this.Caption = thisform.Combo1.RowSource
	ENDPROC
	
	PROCEDURE command2.Click
		thisform.BindControls = .T.
	ENDPROC

ENDDEFINE
this is a funny example:
this form work, but every ControlSource is blank!

edit text1 and go into text2 ...
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form


	autocenter = .T.
	Height = 399
	Width = 561
	DoCreate = .T.
	Caption = "Form1"
	BindControls = .F.
	Name = "Form1"


	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "cc.ff", ;
		Height = 23, ;
		Left = 184, ;
		Top = 47, ;
		Width = 100, ;
		Name = "Text1"


	ADD OBJECT text2 AS textbox WITH ;
		ControlSource = "cc.ff", ;
		Height = 23, ;
		Left = 186, ;
		Top = 87, ;
		Width = 100, ;
		Name = "Text2"


	PROCEDURE Init
		this.BindControls=.T. && this force a controlsource eval at this point

		this.BindControls=.F. && stop
                 
                * blank all
		thisform.setall("ControlSource"," ") && look space(1)

		* thisform.setall("ControlSource","")  && empty string don't respect BindControls = .F.

		replace cc.ff WITH "new value"
	ENDPROC


	PROCEDURE Load
		CREATE CURSOR cc (ff C(10))
		INSERT INTO cc (ff) VALUES ('1234567890')
	ENDPROC


	PROCEDURE text1.Valid
		thisform.text2.Refresh
	ENDPROC


ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform