Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cancel Button on Modified mmMaintenanceForm
Message
From
24/04/2008 19:35:25
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
To
24/04/2008 18:33:35
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Novell 6.x
Database:
MS SQL Server
Miscellaneous
Thread ID:
01312518
Message ID:
01313033
Views:
17
>>Hi Frank,
>>
>>
>>>Hi, Tim,
>>> I tried your code.
>>> Based on my reading of your explanation, specifically the phrase "your form", I placed the code you suggested in my modified mmMaintenanceForm. If I have misunderstood, please advise.
>>> Regardless, that didn't work.
>>> I then tried the equivalent code in the end user form in my application.
>>> That didn't work either.
>>> I have verified that the code does not execute in either case.
>>>
>>> I have also verified that mmButtonCancel_Click in mmButtonCancel.cs and CancelHandler in mmButtonHelper do execute, as expected.
>>>
>>> I also tried Kevin's suggestion, in the modified mmMaintenanceForm and in my end user form.
>>> No joy there either.
>>>
>>> I'm a long time Fox developer who's now learning .Net. If I was trying this in VFP it would be a couple of lines of obvious code and I'd be done. What makes it so difficult using .Net?
>>>
>>> Sorry for the kvetch. It seems like this should be dead easy and it's proving to be anything but. It's frustrating.
>>>
>>> As usual, any further suggestons or help will be much appreciated.
>>>
>>>Thanks,
>>>Frank
>>
>>Here is what I tried:
>>I set the CancelButton property of the form to my cancel button.
>>I set the FocusOnCancel property to the listPage and it didn't do anything. Then I created a handler for the cancel button like below and it called the cancel alright, but didn't re-focus based on the FocusOnCancel property.
>>
>>So I override the Cancel method for the form like I showed you (also shown below), and added the SetFocus() method and that didn't work either, so I just added a TabControl.SelectedIndex = 0 and that did the trick.
>>
>>Maybe Kevin can elaborate more about the property and the method that should work. I will look at his code a little later to see what it does and maybe trace it in the debugger.
>>Tim
>>
>>
>>
>>public override void Cancel()
>>{
>>	base.Cancel();
>>	// This didn't work
>>	this.SetFocus(this.ListPage);
>>	// But this did.
>>	this.TabControl.SelectedIndex = 0;
>>}
>>
>>private void mmButtonCancel1_Click(object sender, EventArgs e)
>>{
>>	this.Cancel();
>>}
>>
>
>
>A little more info Frank,
>
>After reading the dev guide topic "Specifieing the Control to receive focus" under "Creating Windows Forms Applications" I got the impression you couldn't SetFocus to a tab on a tab control. I then changed my above code to this.SetFocus(this.lblLabel); and it worked. So taking that a step further, I removed that code and placed the lblLabel control (which is on the list page) in the FocusOnCancelControl property and that did not work. If you read that topic in the dev guide "Creating a Maintenance Form" it does say to select a different tab on a page after save or cancel to add the click event of the button and just use this.TabControl.SelectedPage = this.ListPage;
>
>I hope this helps, and Kevin can maybe explain further the property that I can't get to work either.
>
>Tim

Well the property for FocusOnCancelControl works in the sample application with it set to the btnNew control. There isn't any additional code or methods in the sample app for this to work. Since I wasn't actually retrieving any data in my test I suspect that had something to do with why the cancel method wasn't firing until I forced it. Frank, you may want to look through the sample Employee maintenance form and compare to what you are doing.
Tim
Timothy Bryan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform