Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Dynamically Add Valid Method

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
US
I have a form with an existing grid. In certain circumstances I need to dynamically add a column to the end of the grid. The problem is that the text box for that column needs to have a VALID event built also. This is what I have so far:

Code:
	LOCAL nCurrentColumnCount
	nCurrentColumnCount = this.ColumnCount 
	this.ColumnCount = nCurrentColumnCount + 1
	this.Column1.FontSize = 8
	this.Column1.ControlSource = "evtmp.assgn_brkr"
	this.Column1.Width = 50
	this.Column1.Name = "colAssignBroker"

	this.ColAssignBroker.header1.Caption = "Asgn To"
	this.ColAssignBroker.text1.Name = "txtAssignedTo"
	this.ColAssignBroker.txtAssignedTo.InputMask = "!!!!"

I tried adding a simple "WAIT WINDOW 'Valid Fired' TIMEOUT 2" to this.ColAssignBroker.valid but it said that Valid is Read-Only. How can I set up the VALID method.

Steve
 
Steve,

One option would be to use BINDEVENT(). Essentially, you create a method of the grid containing the code you want in the column's Valid event. You do that at design time. Then, after you have added the column, you call BINDEVENT() to bind the column's Valid to the method in the grid.

This only works in VFP 8.0 and above.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Another way would be to have a pre-made textbox class that you add to your column and use instead of the default. It can have anything you like in it.
 
Mike,

Although we are doing our developing in VFP 8, the application is deployed in 6 so we have to avoid any functionality that doesn't exist in 6.

Dan,

That's a possibility. I'll have to experiment and see if that works.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top