Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid Programmatically
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00293493
Message ID:
00293518
Views:
25
>Hi Alan,
>
>>When I tried to do this, I set a for loop in the class definition to create the number of columns needed. I get an error that tells me a for loop in invalid in a class definition. Is there a way around this?
>
>I don't understand, what is your class definition based on? WHat does the code look like (go to class browser and click "View CLass COde" button)?

Here is the code I'm working with. This works but in this case I only have three columns. some times there may be 5 or 6. I'm sure there is a better way to do this. (don't laugh)
lParameters lcSource 
lnFCount=FCount(lcSource)
With _SCREEN.ActiveForm
.AddObject('MyGrid','MyGrid')
.MyGrid.Visible=.T.
EndWith

With _SCREEN.ActiveForm.MyGrid
.ColumnCount = lnFCount 
.DeleteMark = .F.
.Height = 200
.Left = 0 
.RecordSource = lcSource
.Top = 150
.Visible = .T.
.Width = 618
.Name = "MyGrid"
For lnCount = 1 to lnFCount
	.Columns(lnCount).Width=FSize(Field(lnCount))*5
	.Columns(lnCount).Header1.Caption=Field(lnCount)
EndFor
EndWith

Define Class MyTextBox as TextBox
Procedure DblClick()
	MessageBox("Test dblclick")
EndProc
EndDefine

Define Class MyColumn as Column
Add Object MyTextBox As MyTextBox
EndDefine 

DEFINE CLASS MyGrid AS Grid
ADD OBJECT MyColumn1 As MyColumn
ADD OBJECT MyColumn2 As MyColumn
ADD OBJECT MyColumn3 As MyColumn
ADD OBJECT MyColumn4 As MyColumn
EndDefine
Alan Trosky
MIS Director
Pennsylvania Bar Association
Harrisburg PA 17108
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform