Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I write Validate or InterActiveChange code for g
Message
From
27/08/1999 21:36:55
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
27/08/1999 17:26:41
Pamela Bulmahn
The University of Iowa
Iowa, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00258675
Message ID:
00258733
Views:
10
>I have a form with a grid that has a varying number of columns based on user input. I want to Validate user entry, add the value entered by the user to the total in the last column and have some kind of an on key command to do something else with the user entered number.
>
>I created the form with the grid on it, without and column count or recordsource. When the user gives the form enough information, I set the grid up with the necessary number of columns and attach it to a record source. Then I go thru and assign controlsource for each column. That all works just right. But I can't figure out how to, or where to put event code when I don't have the columns at design time.
>
>Thanks for any assistance you may provide.
>Pamela
Pamela,
You could use addcolumn() to add a userdefined column. It would be nonvisual though. Since you want this at runtime there is no problem. Another possibility is having the code at grid level (ie:using before/afterrowcolchange).
Clear all
ON key label "F2" clear events
USE (home()+"samples\data\customer")
oForm = createobject("Form")
oForm.Addobject("oTemp","MyGrid")
WITH oForm.Otemp
ENDWITH
oForm.Otemp.visible = .t.
oForm.show()
READ events

DEFINE CLASS MyForm AS Form
  PROCEDURE Click
    = MESSAGEBOX('MyForm has been clicked!')
  ENDPROC
ENDDEFINE

DEFINE class mygrid as grid
  PROCEDURE addcolumn
    LPARAMETERS nIndex, cAlias, cField
    NODEFAULT
    this.addobject("clm"+cField,"mycolumn", cAlias+"."+cField,nIndex)
  ENDPROC
  PROCEDURE init
    WITH this
      nOldColCount = .columncount
      FOR ix = 1 to fcount()
        .AddColumn(ix, alias(), field(ix))
      ENDFOR
      FOR ix = nOldColCount to 1 step -1
        .RemoveObject(.Columns(ix).name)
      ENDFOR
    ENDWITH
  ENDPROC
ENDDEFINE
DEFINE class mycolumn as column
  DynamicBackColor = "iif(recno()%2=0,rgb(192,192,192),rgb(255,0,0))"
  PROCEDURE init
    LPARAMETERS cControlSource, ncopycol
    this.controlsource = cControlSource
    this.width = this.parent.columns(ix).width
    this.removeobject("Header1")
    this.addobject("Header1","myHeader",this.parent.columns(ix).header1.caption)
    *	this.header1.caption = this.parent.columns(ix).header1.caption
  ENDPROC
  PROCEDURE mousemove
    LPARAMETERS nButton, nShift, nXCoord, nYCoord
    WAIT window nowait "Focused on "+this.name
  ENDPROC
ENDDEFINE
DEFINE class myheader as header
  BackColor = rgb(255,255,255)
  ForeColor = rgb(0,0,255)
  PROCEDURE init
    LPARAMETERS tcCaption
    this.caption = tcCaption
  ENDPROC
  PROCEDURE click
    this.parent.columnorder = 1
  ENDPROC
ENDDEFINE
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform