StrataFrame Forum

Simulating Clicking on New/Edit buttons on MFTS

http://forum.strataframe.net/Topic9411.aspx

By Tim Dol - 6/7/2007

In my form constructor I passing the initial editing state for the form. What event should I be adding my code to change the editing state based on my parameter, so it maintains the same functionality as clicking on New or Edit button.

Right now I have my code in the ParentFormLoading event of my primary business object. It does change the editing state correctly, but it will not honor the form properties 'FocusControlOnAdd and FocusControlOnEdit'. 

Thanks,

Tim

By Trent L. Taylor - 6/7/2007

Well, all you really need to do is call the Edit() or Add() on the form and it will do the same thing as clicking the New or Edit on the MaintenanceFormToolstrip.  So just pass over your parm, and if it is add, then just call the Add() on the form and it will do the same thing as the MFToolstrip.
By Tim Dol - 6/7/2007

That's exactly what I'm doing, and it does seem to work, except for setting focus on the assigned control. I tried my code in a number of events, including the Form Load event.  Do you happen to know if there is an Form event that gets fired when all business objects and form stuff has been completed?
By Trent L. Taylor - 6/7/2007

Yeah, and this actually won't work correctly when the form is loading due to the initialization sequence.  All I would do is look at the FocusControlOnAdd or FocusControlOnEdit property and do this yourself.

If me.FocusControlOnAdd IsNot Nothing Then
     me.FocusControlOnAdd.Focus()
End If

You may need to do this in the Shown event of the form in order to make this work properly with the Focus().

By Tim Dol - 6/8/2007

Your suggestion worked fine.  Smile

Thanks

Tim