Quantcast

Maximum PC

It is currently Wed Jul 23, 2014 6:45 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: de-selecting radio buttons in VB.NET
PostPosted: Thu Feb 24, 2005 5:20 pm 
Little Foot
Little Foot

Joined: Sun Aug 08, 2004 5:30 am
Posts: 147
Location: Qo'nos
Hey,

I've got three radio buttons on a form, along with a button that says "Cancel". Suppose the user selected one of the radio buttons and then clicked the cancel button. How would I code the cancel button's click event procedure so that it would de-select whatever radio button the user clicked on, leaving all three of them empty?

I did some digging on Google, and found lots of data on how to determine if a radiobutton had been selected, but can't figure out how to de-select them.

Does that make sense? Yhea, I suck at VB.NET, but I'm getting better. :wink:


Top
  Profile  
 
 Post subject: Re: de-selecting radio buttons in VB.NET
PostPosted: Fri Feb 25, 2005 10:00 am 
Thunderbird
Thunderbird
User avatar

Joined: Wed Jul 07, 2004 1:13 pm
Posts: 817
Location: Missouri
Treklink256 wrote:
Hey,

I've got three radio buttons on a form, along with a button that says "Cancel". Suppose the user selected one of the radio buttons and then clicked the cancel button. How would I code the cancel button's click event procedure so that it would de-select whatever radio button the user clicked on, leaving all three of them empty?

I did some digging on Google, and found lots of data on how to determine if a radiobutton had been selected, but can't figure out how to de-select them.

Does that make sense? Yhea, I suck at VB.NET, but I'm getting better. :wink:


I am not sure how to do this in .NET version but in VB6 you can do this by naming the object and then its properties like this. rdo1.value = unchecked.


Top
  Profile  
 
 Post subject:
PostPosted: Sat Feb 26, 2005 4:44 pm 
Little Foot
Little Foot

Joined: Wed Nov 10, 2004 7:28 am
Posts: 155
you have to set the checked funtion to false and example is RadioButton1.Checked = False


Top
  Profile  
 
 Post subject:
PostPosted: Sun Feb 27, 2005 2:40 pm 
Little Foot
Little Foot

Joined: Sun Aug 08, 2004 5:30 am
Posts: 147
Location: Qo'nos
Quote:
you have to set the checked funtion to false and example is RadioButton1.Checked = False

Well, I know THAAAT, I guess I should be more specific :roll:

I'm trying to write a loop that will do that to every radio button on the form.

Here's an example of what I'm trying to do (code below doesn't work, but I think you'll get the idea);

Code:
dim objControl as new control
for each objControl in form1
     if typeof controls.item is radiobutton then
          radiobutton.checked=false
     end if
next objControl

Or something like that.

Thanks for the suggestion, though!


Top
  Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 3:29 pm 
Little Foot
Little Foot

Joined: Wed Nov 10, 2004 7:28 am
Posts: 155
why write a loop once there all unchecked then it wont execute agian. Do you want a buttion that does that if so just draw the buton on form double click it and in the routine just put the uncheck code in for each button.


Top
  Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 3:23 pm 
Little Foot
Little Foot

Joined: Sun Aug 08, 2004 5:30 am
Posts: 147
Location: Qo'nos
Quote:
why write a loop once there all unchecked then it wont execute agian

Exactly. Why keep executing the loop once there's nothing left to uncheck? :P
Quote:
Do you want a buttion that does that if so just draw the buton on form double click it and in the routine just put the uncheck code in for each button.

Yhea, that's how I'm doing it for now. I've got quite a few radio buttons on this form, and I feel a little silly typing in 14 different unchecked = false commands - especially if there's a way I can write a loop to uncheck all 14 w/6 lines of code, it seems like that would be more efficient.

Not a huge deal, just seems odd.

NCC-1701-D Forever!


Top
  Profile  
 
 Post subject:
PostPosted: Mon Mar 07, 2005 10:38 am 
Little Foot
Little Foot

Joined: Wed Nov 10, 2004 7:28 am
Posts: 155
I just finished a Semester of VB.net and one thing i learned about it is that if it seems to be a dumb solution its probably right. VB.net is kinda weird like that. Only way I could think a loop would work is that you have it cycle through all the objects on the form and check to see if its a radiobutton and if it is then set carry the name as a variable and use it to set it to false. probably would just be easier to do the uncheck un less you got 100+ radiobuttons.


Top
  Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group