473,399 Members | 2,774 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,399 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 1259
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

7
by: steve | last post by:
Hi all If I use this code <% If Request.Item("col")="firstcoll" Then Response.Write "Checked"%> in .aspx page for example like that <input type="radio" name="col" value="firstcoll" <% If...
2
by: steve | last post by:
Sorry if I have post this two times. Hi all What I'm trying to achieve is: I have a form with two radio buttons, if a visitors check radio button 2 and click submit in the next page radio...
4
by: Altman | last post by:
I want to start a timer when an object loads, so I put the code to start it in the constructor. The problem I am having is that when I put the object on a form in development it starts the timer. ...
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...
1
by: leedspaddy | last post by:
Hi there, I set the default value of a combo box on a form using the following code in the properties box: cboContactType.itemdata(0) and of course nothing happens. I just want the combo box to...
0
by: rhepsi | last post by:
hii all, I have a database... wherein, a field is: wo_gender wo_gender =M, F or null(default) i have 153 records, now in the worker-->search form, i have a group box (gender) within tht...
2
by: puT3 | last post by:
I have Customer table where there is a field called Company Type which store corporate or private. I want to retrieve the value in the table so it is diplayed on classic asp file in radio button. Im...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
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
isladogs
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...

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.