472,358 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

disabling controls by checking off a radio button when the form loads

Hi,
I have 2 radio buttons on my Windows form control. The radio button's
CheckedChanged event disables or enables other controls on the form based on
the value of the Checked property.
When the form loads, I want to check off one of the radio buttons. So I
put the code to check off my radio button in the form's load event. But the
CheckedChanged even is not firing.

Private Sub ActivityList_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' check the Unscheduled Activity radio button

rdoUnscheduledActivity.Checked = True

End Sub

This code is not firing the CheckedChanged event of the radio button.

Any help will be appreciated.

Thanks in advance...
Mar 31 '06 #1
8 1994
Only thing I can think of is if rdoUnscheduledActivity's Checked property is
set to True at the design time then in Form Load event setting it again to
True will not fire that event.
Mar 31 '06 #2
Hi,

You did not post the code that you're using as a handler for your
CheckedChanged event.

Two possible reasons come to my mind, which might explain the problem :

1. The Eventhandler is not wired to the Event. i.e., the method
Private Sub rdoUnscheduledActivity_CheckedChanged() does not have a
Handles clause to connect it to the event.

2. If the radio button is already checked and you set it's checked
property to True, the CheckedChanged event won't fire. Though, in this
case, it probably won't be possible, since even if you set the Checked
property of the Radio button to True in Design mode, the event will
still fire when InitializeComponent sets that setting. (Pardon the long
sentence.)

Regards,

Cerebrus.

Mar 31 '06 #3
"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi,

You did not post the code that you're using as a handler for your
CheckedChanged event.

Two possible reasons come to my mind, which might explain the problem :

1. The Eventhandler is not wired to the Event. i.e., the method
Private Sub rdoUnscheduledActivity_CheckedChanged() does not have a
Handles clause to connect it to the event.

2. If the radio button is already checked and you set it's checked
property to True, the CheckedChanged event won't fire. Though, in this
case, it probably won't be possible, since even if you set the Checked
property of the Radio button to True in Design mode, the event will
still fire when InitializeComponent sets that setting. (Pardon the long
sentence.)


Actually, #2 is possible. The Designer sets properties before adding event
handlers in InitializeComponent.
Apr 1 '06 #4
Please note that crossposting is considered rude. Please note that this has
nothing to do with the C# programming language. When crossposting any of
your problems again, please omit the csharp group.
Thanks.

"helpful sql" <no****@stopspam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,
I have 2 radio buttons on my Windows form control. The radio button's
CheckedChanged event disables or enables other controls on the form based
on the value of the Checked property.
When the form loads, I want to check off one of the radio buttons. So I
put the code to check off my radio button in the form's load event. But
the CheckedChanged even is not firing.

Private Sub ActivityList_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' check the Unscheduled Activity radio button

rdoUnscheduledActivity.Checked = True

End Sub

This code is not firing the CheckedChanged event of the radio button.

Any help will be appreciated.

Thanks in advance...

Apr 1 '06 #5
Hi James,
Actually, #2 is possible. The Designer sets properties before adding event
handlers in InitializeComponent.


Could you elaborate on how #2 is possible ? I actually tried this. I
set the Checked property to True in Design mode. Then implemented an
Event handler for the CheckedChanged event. I then set breakpoints
within the InitializeComponent, where the property is set, and within
the Eventhandler.

As I have mentioned, the program breaks within the Initialize
component, and even before proceeding to the next line, the
CheckedChanged event is raised.

Regards,

Cerebrus.

Apr 1 '06 #6
"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hi James,
Actually, #2 is possible. The Designer sets properties before adding
event
handlers in InitializeComponent.


Could you elaborate on how #2 is possible ? I actually tried this. I
set the Checked property to True in Design mode. Then implemented an
Event handler for the CheckedChanged event. I then set breakpoints
within the InitializeComponent, where the property is set, and within
the Eventhandler.

As I have mentioned, the program breaks within the Initialize
component, and even before proceeding to the next line, the
CheckedChanged event is raised.


I did what you did and the event isn't raised. Looking at my
InitializeComponent(), I can't see how it could.

private void InitializeComponent()
{
// snip
this.radioButton1.Checked = true;
// snip
this.radioButton1.CheckedChanged += new
System.EventHandler(this.radioButton1_CheckedChang ed);
// snip
}

If I hand-modify it and move the latter statement before the former, then
the event goes off. But as it is, no go.

Apr 1 '06 #7
"James Park" <fa******@fakeaddress.com> wrote in message
news:43**********************************@microsof t.com...
"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Hi James,
Actually, #2 is possible. The Designer sets properties before adding
event
handlers in InitializeComponent.


Could you elaborate on how #2 is possible ? I actually tried this. I
set the Checked property to True in Design mode. Then implemented an
Event handler for the CheckedChanged event. I then set breakpoints
within the InitializeComponent, where the property is set, and within
the Eventhandler.

As I have mentioned, the program breaks within the Initialize
component, and even before proceeding to the next line, the
CheckedChanged event is raised.


I did what you did and the event isn't raised. Looking at my
InitializeComponent(), I can't see how it could.

private void InitializeComponent()
{
// snip
this.radioButton1.Checked = true;
// snip
this.radioButton1.CheckedChanged += new
System.EventHandler(this.radioButton1_CheckedChang ed);
// snip
}

If I hand-modify it and move the latter statement before the former, then
the event goes off. But as it is, no go.


Whoops. Totally missed that the OP is using VB. I saw the thread from the
csharp group and made a bad assumption.

Apr 1 '06 #8
>>Whoops. Totally missed that the OP is using VB. I saw the thread from the
csharp group and made a bad assumption.


Ah ! I suspected as much...

So Lebesgue's comments about cross-posting to newsgroups seem even more
appropriate.

Regards,

Cerebrus.

Apr 1 '06 #9

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

Similar topics

8
by: Matthew Louden | last post by:
why need to set autopostback property to be true?? I know autopostback event means to send the form to the server automatically. I tried checkbox, checkbox list, radio button, and radio button...
1
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
2
by: dougawells | last post by:
Hi- I'm wanting to have a set of radio buttons disabled when a form is displayed, then if they check another specific radio button, those would become enabled. I've tried setting it via...
8
by: helpful sql | last post by:
Hi, I have 2 radio buttons on my Windows form control. The radio button's CheckedChanged event disables or enables other controls on the form based on the value of the Checked property. When the...
7
by: nathaniel.k.lee | last post by:
Is it not possible, in IE, to dynamically click a radio button? I'm grabbing some values from a database and using them to populate radio buttons on a page. I have alternate code for Firefox...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
1
by: Suma | last post by:
Hi, i have a problem with the controls .i have to validate Form1 Radio button option is checked or Not in the Form2. even after checking the radio button also in FOrm2 it is always taking as...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...

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.