Hi there, sorry if this is a really simple question.
I need to write code for:
If a button is pushed and then one variety of other buttons is pushed
then certain options on the program will become "greyed out". Ie they
can no longer be selected.
I assume i need to create an event from the first button being pushed
and then do if statements depending which button is pushed next
(IE. First Button is pushed,
If Button 2 is pushed then
buttons 6 and 8 become unusable
Else If Button 3 is pushed then
buttons 5 and 9 become unusable)
The problem i have is how do u put a button click in an if statement?
Please Please help.....this is driving me mad!
Kind Regards,
Code
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
---------------------------------------------------------- http://www.usenet.com 7 41758
You might try something along the lines below where you name the buttons
But1, But2, etc:
Private Sub button_Click(By Val sender As System.Object, ByVal e As _
System.EventArg s) Handles button1.Click, button2.Click, button3.Click, _
button4.Click, button5.Click, button6.Click
Select Case DirectCast(send er,button).Name
Case "but1"
button_Click (Me.but1, e)
Case "but2"
but5.Enabled=Tr ue:but9.Enabled =True
but6.Enabled=Fa lse:but6.Enable d=False
case "but3"
but5.Enabled=Tr ue:but6.Enabled =True
but5.Enabled=Fa lse:but9.Enable d=False
buttons 5 and 9 become unusable)
End Select
End Sub
"code100579 " wrote: Hi there, sorry if this is a really simple question. I need to write code for:
If a button is pushed and then one variety of other buttons is pushed then certain options on the program will become "greyed out". Ie they can no longer be selected.
I assume i need to create an event from the first button being pushed and then do if statements depending which button is pushed next
(IE. First Button is pushed, If Button 2 is pushed then buttons 6 and 8 become unusable Else If Button 3 is pushed then buttons 5 and 9 become unusable)
The problem i have is how do u put a button click in an if statement? Please Please help.....this is driving me mad! Kind Regards, Code
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
"code100579 " <ro********@hot mail-dot-com.no-spam.invalid> wrote in message
news:42******** @127.0.0.1... Hi there, sorry if this is a really simple question. I need to write code for:
If a button is pushed and then one variety of other buttons is pushed then certain options on the program will become "greyed out". Ie they can no longer be selected.
I assume i need to create an event from the first button being pushed and then do if statements depending which button is pushed next
(IE. First Button is pushed, If Button 2 is pushed then buttons 6 and 8 become unusable Else If Button 3 is pushed then buttons 5 and 9 become unusable)
The problem i have is how do u put a button click in an if statement? Please Please help.....this is driving me mad! Kind Regards,
OK, this may well not be the best way, but here are a couple of
possibilities.. .
From your description, buttons 2 and 3 have no functionality unless button 1
has been clicked, correct?
Disable buttons 2 and 3, and enable them in code only when button 1 is
clicked, then when the user clicks either 2 or 3, do as you've stated.
If buttons 2 and 3 *do* have associated functionality independent of button
1, consider making them fully independent and using, say, radio buttons
(enabled when the user clicks button 1) to allow the user make the choice
between which other buttons are enabled/disabled.
Or, you could use a class level variable to indicate that button one has
been clicked and test the variable in the event procedures for buttons 2 and
3. A Boolean would work well here. Set it in the event procedure for button
1, then be sure to housekeep the variable, once used, in the event
procedures for buttons 2 and 3.
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Hi,
Did you try the button's performclick() method?
if .....
button1.perform click()
end if
Bernie Yaeger
"code100579 " <ro********@hot mail-dot-com.no-spam.invalid> wrote in message
news:42******** @127.0.0.1... Hi there, sorry if this is a really simple question. I need to write code for:
If a button is pushed and then one variety of other buttons is pushed then certain options on the program will become "greyed out". Ie they can no longer be selected.
I assume i need to create an event from the first button being pushed and then do if statements depending which button is pushed next
(IE. First Button is pushed, If Button 2 is pushed then buttons 6 and 8 become unusable Else If Button 3 is pushed then buttons 5 and 9 become unusable)
The problem i have is how do u put a button click in an if statement? Please Please help.....this is driving me mad! Kind Regards, Code
Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
> Private Sub button_Click(By Val sender As System.Object, ByVal e As _ System.EventArg s) Handles button1.Click, button2.Click,
button3.Click, _ button4.Click, button5.Click, button6.Click Select Case DirectCast(send er,button).Name Case "but1" button_Click (Me.but1, e)
This will cause a stack overflow as you will continue to execute this
code over and over.
I suggest something similar to what Dennis suggested.
'Boolean variable to indicate if Button1 is pushed
Public bButton1Pushed As Boolean
Private Sub button_Click(By Val sender As System.Object, ByVal e As _
System.EventArg s) Handles button1.Click, button2.Click, button3.Click,
_
button4.Click, button5.Click, button6.Click
Select Case DirectCast(send er,button).Name
Case "but1"
bButton1Pushed = True
Case "but2"
If bButton1Pushed Then
but6.Enabled = True
but8.Enabled = True
bButton1Pushed = False 'Reset the variable for the
next time
Else
'Code to run if Button1 wasn't pushed first
End If
case "but3"
If bButton1Pushed Then
but5.Enabled = True
but9.Enabled = True
bButton1Pushed = False 'Reset the variable for the
next time
Else
'Code to run if Button1 wasn't pushed first
End If
End Select
End Sub
> Private Sub button_Click(By Val sender As System.Object, ByVal e As _ System.EventArg s) Handles button1.Click, button2.Click,
button3.Click, _ button4.Click, button5.Click, button6.Click Select Case DirectCast(send er,button).Name Case "but1" button_Click (Me.but1, e)
This will cause a stack overflow as you will continue to execute this
code over and over.
I suggest something similar to what Dennis suggested.
'Boolean variable to indicate if Button1 is pushed
Public bButton1Pushed As Boolean
Private Sub button_Click(By Val sender As System.Object, ByVal e As _
System.EventArg s) Handles button1.Click, button2.Click, button3.Click,
_
button4.Click, button5.Click, button6.Click
Select Case DirectCast(send er,button).Name
Case "but1"
bButton1Pushed = True
Case "but2"
If bButton1Pushed Then
but6.Enabled = True
but8.Enabled = True
bButton1Pushed = False 'Reset the variable for the
next time
Else
'Code to run if Button1 wasn't pushed first
End If
case "but3"
If bButton1Pushed Then
but5.Enabled = True
but9.Enabled = True
bButton1Pushed = False 'Reset the variable for the
next time
Else
'Code to run if Button1 wasn't pushed first
End If
End Select
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Philip Townsend |
last post by:
I have an aspx page that contains 2 user controls, each containing a
seperate textbox and button. I would like to specify that one of the
buttons recieve focus when the page loads. Also, I would like that same
button to fire its event when the user presses enter. Can anybody help
with this?
*** Sent via Developersdex...
|
by: H Branyan |
last post by:
Scenario:
When a user submits the form by clicking one button (ButtonA), I want to
fire the click event for another button (ButtonB).
I created a javascript function first to the webform:
function SaveForm(btnName) {
alert('Save Form click ' + btnName);
var btn = document.forms;
btn.click();
|
by: JCE |
last post by:
I need to programmatically invoke an asp:Button click event from a
javascript function. The page containing the script and the button is the
HTML page associated with a WebUserControl-derived object (both the HTML and
control are built in the same .ascx file)
The target button simply fires an event in the WebUserControl-derived
object. So,...
|
by: Antonio Policelli |
last post by:
hello, i want to have 10 buttons on a form and all will do almost
exactly the same thing except for one differnece. can i use the tag
property of each button in the same sub?
private sub allbuttonsclick (ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles Button1.Click, Button2.Click, Button3.Click,
Button4.Click,...
|
by: mark |
last post by:
Is there a means of raising an event when ANY button on a windows application
form is clicked wherein the actual button clicked can be determined in the
generic click events code (eg by way of interogating the sender)?
--
mark
| |
by: bay_dar |
last post by:
Hi, I have an internal ASP.NET application that I'm are using to send
e-mails out based on a single milepost or milepost range entered.
I'm trying to do two things when a user clicks on the submit button
to submit a form that contains one or two Mileposts:
1) If a Milepost range larger than 5 miles is entered, I would
like to
pop...
|
by: plumba |
last post by:
Ok, another query....
I have a checkbox at the bottom of my form which when checked unhides a <div> block which displays the submit button.
The problem I have is when the clear form button is pressed it removes the check but does not re-hide the submit <div> bit.
The way i see it, I have 3 options:
1) To simply remove the clear for...
|
by: Dennis |
last post by:
I have a page in ASP.NET 2.0. I add a button in design view and the
page runs fine. I then double-click the button to create the click
method in the code. Then when I run the page I get the error "error
BC30506: Handles clause requires a WithEvents variable defined in the
containing type or one of its base types."
I have tried deleting...
|
by: Hrvoje Vrbanc |
last post by:
Hello all!
As I have only recently started to use native ASP.NET 2.0 data access
controls (and found them to be very powerful), I have one question that I
was unable to find the answer to:
- I have an ASPX page with a SqlDataSource control with Select, Update and
Delete calls to stored procedures and a GridView bound to SqlDataSource,
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |