473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to Close Form using a custom button control.

I'm trying to create a custom button control, and have the onclick event
close the form. I was thinking I would use this.Parent,Close() but close()
isn't in the drop down list. How can I do this?
Nov 17 '05 #1
2 2077
that's because Parent is a Control not a form
you'll need to cast Parent to a form to call Close
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...
I'm trying to create a custom button control, and have the onclick event
close the form. I was thinking I would use this.Parent,Close() but
close()
isn't in the drop down list. How can I do this?

Nov 17 '05 #2
Actually, the FindForm method seems to do the job.

protected override void OnClick( EventArgs e )
{
base.OnClick( e ) ;
Form form = (Form)this.FindForm();
form.Close();

}

"Alejandro González" wrote:
that's because Parent is a Control not a form
you'll need to cast Parent to a form to call Close
"Vern" <Ve**@discussions.microsoft.com> wrote in message
news:C7**********************************@microsof t.com...
I'm trying to create a custom button control, and have the onclick event
close the form. I was thinking I would use this.Parent,Close() but
close()
isn't in the drop down list. How can I do this?


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Reggie | last post by:
Hi and TIA! I have a form and have set the Close Button to false so that users must exit using my close button. However when I open a Report from this form I want the close button to be available...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
3
by: Todd Schinell | last post by:
Back in July, Jeffery Tan posted this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OWOTdf0VDHA.2296%40cpmsftngxa06.phx.gbl In response as to how to get click events from a...
1
by: Vi | last post by:
I have a web form that is submitted using an <asp:Button> control. On this form I want to do some client side validation using the onsubmit event of the form (client side). In order to do that I'm...
5
by: Stan Sainte-Rose | last post by:
Hi, Which event is called when the user click on the close window icon (X) ? I want, when he clicks on this icon, to display a message before closing the form. If he replys by No, I don't want to...
3
by: MikeY | last post by:
Hi everyone, I'm having problems, or should I say still having problems with trying to pass data from my custom buttons in my custom controls to my main form listview box. Still scratching my...
9
by: mohit.akl | last post by:
Hey guys & gals I am havng trouble modifying the control box. I want to make the maximise button invisible and have minimisise button instead of it. Like this _ X (not like _ o X ) How...
8
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
1
by: rn5a | last post by:
A custom server control has a Button. Namespace Confirm Public Class ShowConfirm : Inherits Button Private strConfirmMsg As String Public Property ConfirmMessage() As String Get...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.