473,503 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Click event in an If to check if already clicked...

2 New Member
Hello,

I have a custom maximize box made for my application. I want it to be so that when I click it once then it maximizes, but if I click it again, it returns to the previous size. My code:
Expand|Select|Wrap|Line Numbers
  1.     Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
  2.         Me.WindowState = FormWindowState.Maximized
  3.         If WindowState = FormWindowState.Maximized Then
  4.             If PictureBox3.click() Then Close()
  5.         End If
  6.     End Sub
Error: is an event handler and cannot be called directly, use "raiseevent" instead.
Aug 3 '15 #1
2 2099
AwesomeNexus
2 New Member
Ok, i put if event and it seems ok but says expression expected. WTH?
Aug 3 '15 #2
!NoItAll
297 Contributor
I don't think you can do:
Expand|Select|Wrap|Line Numbers
  1. If PictureBox3.click() then Close
First off PictureBox3.click is a method and it does not return a boolean.
Second - calling Picturebox3.click inside PictureBox3_click (which handles Picutebox3.click) is recursive and bound to just get you into trouble...
Instead try...
Expand|Select|Wrap|Line Numbers
  1. Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
  2.         Static bClicked as Boolean = False
  3.         if bClicked = False then
  4.             bClicked = True
  5.             Me.WindowState = FormWindowState.Maximized
  6.         End if
  7.     End Sub
  8.  
Of course you have no way to then minimize or normalize the form. Instead I would recommend you set it up as a toggle...
Expand|Select|Wrap|Line Numbers
  1. Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles PictureBox3.Click
  2.         If Me.WindowState = FormWindowState.Maximized Then
  3.             Me.WindowState = FormWindowState.Normal
  4.         Else
  5.             Me.WindowState = FormWindowState.Maximized
  6.         End If
  7. End Sub
  8.  
This sets up a nice toggle between normal and maximized.
Aug 19 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3596
by: simonmarkjones | last post by:
Hi i've just started using check boxes on my form. When the check box is clicked i want to test a condition is met (in my database i'm only allowing certain users to click the check box to void...
5
6159
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this...
3
6673
by: JD | last post by:
Hello, I have a problem with checkboxlist inside Repeater (in ASP.NET page). I am able to create Checkboxlist and bind it (inside Repeater_ItemBound - including setting checked/unchecked)....
4
4009
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
24
7610
by: Charles Law | last post by:
When I click a button I don't want the click event to fire. Is this possible? In fact, what I would really like is to be able to intercept the click event, perform some action, and then prevent...
41
4237
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
0
2932
by: Demetri | last post by:
I have created a web control that can be rendered as either a linkbutton or a button. It is a ConfirmButton control that allows a developer to force a user to confirm if they intended to click it...
2
2367
by: Chu | last post by:
Thanks everyone for taking a moment to read this. I've got a page where I use a LinkButton and I wire up a dynamic event to the button. When the user clicks the button, the event is fired as...
1
1303
by: ODAN | last post by:
I have an ASP.NET application written in C#. one of the web form where you create user information and user name has a button to click to print selected user information for the users record....
4
1827
by: LyzH | last post by:
Someone else had a question on how to emulate a mouse click. I tried posting in that thread but I have something of a twist on this problem and I'm really in trouble here! If I don't get help...
0
7198
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
7271
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
7319
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...
1
6979
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...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.