Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Container Object not Resizing in Grid
Message
 
À
24/06/2005 17:10:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01026447
Message ID:
01026455
Vues:
22
>I have been doing some more testing. It appears that objects in a grid column have a readonly width property. I can "resize" the container by removing the container and then adding it back again in the column resize event. It does not seem to be the best solution, but it does work.
>
>I have not been able to determine how the default textbox is linked to the column width; if this can be determined, then the container might be linked in the same way for a better approach to resizing. I have tried removing the textbox, but the effect is still the same.


No, you can not for VFP will handle it for you, here is one version I think will work for you, you can see I added an extra container, also made the border of all the textboxes 1 to see if works

[update]
Sorry, my bad, it does not work, I am checking again. Disregard it
[/update]
**************************************************
loForm = CREATEOBJECT("GridForm")
loForm.visible = .T.
READ EVENTS


**************************************************
*
DEFINE CLASS GridForm AS Form
Top = 0
Left = 0
Height = 169
Width = 574
DoCreate = .T.
Caption = "Grid Demostration"
Name = "Form1"


ADD OBJECT grid1 AS grid WITH ;
ColumnCount = 3, ;
Height = 169, ;
Left = 0, ;
Panel = 1, ;
Top = 0, ;
Width = 574, ;
Anchor = 15, ;
Name = "Grid1", ;
Column1.Name = "Column1", ;
Column2.Width = 330, ;
Column2.Name = "Column2", ;
Column3.Name = "Column3"


PROCEDURE Load
CREATE CURSOR c_temp (field1 C(25), field2 C(25), field3 C(25), field4 C(50), field5 C(25))
INSERT INTO c_temp (field1,field2,field3,field4,field5);
VALUES ("Test Data","More Test Data","Yet more test data","This is a longer text phrase","Last text data")
ENDPROC


PROCEDURE Init
WITH thisform.grid1
.Columns(2).Addobject("CellContainer1","CellContainer")
.Columns(2).CurrentControl = "CellContainer1"
.Columns(2).CellContainer1.MultiEdit1.Visible = .T.
.Columns(2).Sparse = .F.
.Rowheight = 45
.recordsource = 'c_temp'
.column1.controlsource = 'c_temp.field1'
.column2.CellContainer1.MultiEdit1.Text1.controlsource = 'c_temp.field2'
.column2.CellContainer1.MultiEdit1.Text2.controlsource = 'c_temp.field3'
.column2.CellContainer1.MultiEdit1.Text3.controlsource = 'c_temp.field4'
.column3.controlsource = 'c_temp.field5'
ENDWITH
ENDPROC


PROCEDURE Resize
ENDPROC


*!*	PROCEDURE grid1.Column2.Resize
*!*	this.MultiEdit1.width = this.Width
*!*	this.MultiEdit1.SetTextColumns()
*!*	ENDPROC
ENDDEFINE


**************************************************
*
DEFINE CLASS MyTextBox AS TextBox
BorderStyle = 0
Margin = 0
ForeColor = RGB(0,0,0)
BackColor = RGB(255,255,255)
ENDDEFINE

define class CellContainer as Container
	add object MultiEdit1 as MultiLineGrid
enddefine

**************************************************
*
DEFINE CLASS MultiLineGrid AS container
Width = 478
Height = 46
BackStyle = 0
BorderWidth = 0
Name = "MultiLineGrid"
Anchor = 10


ADD OBJECT text1 AS textbox WITH ;
BorderStyle = 1, ;
Height = 23, ;
Left = -1, ;
SelectOnEntry = .T., ;
SpecialEffect = 1, ;
Top = -1, ;
Width = 240, ;
Name = "Text1"
Anchor = 10


ADD OBJECT text2 AS textbox WITH ;
BorderStyle = 1, ;
Height = 23, ;
Left = 238, ;
SelectOnEntry = .T., ;
SpecialEffect = 1, ;
Top = -1, ;
Width = 240, ;
Name = "Text2"
Anchor = 10


ADD OBJECT text3 AS textbox WITH ;
BorderStyle = 1, ;
Height = 23, ;
Left = 0, ;
SelectOnEntry = .T., ;
SpecialEffect = 1, ;
Top = 22, ;
Width = 480, ;
Name = "Text3"
Anchor = 10


*-- Sets the text column widths based on container width
PROCEDURE SetTextColumns
this.Text1.Width = INT(this.Width/2) + 1
this.Text2.Width = this.Text1.Width + 1
this.Text2.Left = this.Text1.Width - 2
this.Text3.Width = this.width
ENDPROC


PROCEDURE Init
*LPARAMETERS pnWidth
*this.Width = pnWidth
this.SetTextColumns()
ENDPROC


ENDDEFINE
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform