Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Whos my Parent?
Message
 
To
19/10/2010 10:40:01
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01486099
Message ID:
01486138
Views:
57
Thanks Bonnie,

I will check this out... !!


>Hi Bob,
>
>No reason to jump through any more hoops than necessary. If you always want this Control, with this Button on it to Close the Form it's dropped on, then simply handle the button's Click event, and call ParentForm.Close():
>
>
>// code in custom control
>private void CloseButton_Click(object sender, EventArgs e)
>{
>    this.ParentForm.Close();
>}
>
>
>That's it! It's up to the ParentForm to determine if it's ok to close (in its Closing event handler), but the button has done it's job ... just telling the ParentForm that it should try to Close.
>
>~~Bonnie
>
>
>
>>>>Quick question...
>>>>
>>>>If I have a custom control that is a button and I drop that onto a form and I call that button "Close"
>>>>
>>>>In the click of that button I would like to close the form that it was dropped on... So really, I'd like to define the click event of that button in the actual custom control so that whenever I drop it onto a form, there is no coding involved... It would inherit the code from the custom control... But I cannot find the equivalent of VFP's this.parent.release()...
>>>>
>>>>I do not see where I would be able to use: this.parent.Dispose(false); or this.Parentform.Dispose(false);
>>>>
>>>>Can anyone help me understand this phenomenon??
>>>>
>>>>Thanks,
>>>>Bob
>>>
>>>Robert,
>>>There is a few ways to handle this. One would be to create a property on your button that stores the parent form as a reference. This would require you to set that property on the button however. Are you using a specific base class of your own for your forms? You could also put code in a base class to find the button and set the property or to subscribe to an event raised by the button. Are you using just native dot net stuff or a framework of some kind? Some frameworks have a form manager class that can provide or get the current form for you. Is this Web or Windows forms?
>>>Tim
>>
>>Hi Tim,
>>
>>Thank you for your response... It really is as simple as creating a form in C# and creating a custom control is C#...
>>So native dot net framework, no crazy base classes or anything... I will look into what you said... I also found
>>a web tutorial (http://www.akadia.com/services/dotnet_user_controls.html#Inherited%20controls) that gives me
>>some direction as well..
>>
>>Thanks!!
>>Bob
Previous
Reply
Map
View

Click here to load this message in the networking platform