|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Radio Button Bug?I have 6 radio buttons (control array) on a form, the user selects the option and click the OK button and there are two procedures in my code to enable and disable all controls until the process is complete. but when I disable all the radio buttons the last radio button gets automatically selected. I dont know why its happening. there is no other code for the radio buttons except in the DisableControls procedure. Private Sub DisableControls() Dim i As Integer For i = 0 To optFormat.Count - 1 optFormat(i).Enabled = False Next End Sub anyone experienced the same behavior? forgot to mention. i am also changing the BackColor of all those
radiobuttons at form_load Dim I As Integer For i = 0 To optFormat.Count - 1 optFormat(i).BackColor = Point(0, optFormat(i).Top) Next It would probably be better to place all the radio buttons on a frame or
picturebox then disable the container (frame or picturebox). In this way you do not have to do each button separately. frmButton.Enable = False would disable all buttons on the frame. -- Show quoteHide quoteThe Top Script Generator for Jordan Russell's Inno Setup - http://www.randem.com/innoscript.html Free Utilities and Code - http://www.randem.com/freesoftutil.html "Abhishek" <u***@server.com> wrote in message news:i5cfqm$dl5$1@speranza.aioe.org... > Hi, > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub > > > anyone experienced the same behavior? > >
Show quote
Hide quote
"Abhishek" <u***@server.com> wrote in message I was able to duplicate the problem with VB6+SP5, with SP6 runtime, even if news:i5cfqm$dl5$1@speranza.aioe.org... > Hi, > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub I put them on a frame. However, if I disable the frame first, then the options, then the problem disappears. It's interesting to note that only the last option Click event fires, not while other options are disabled. Another solution that I found is to use EnableWindow() API function. This works fine whether the options are on a frame or not. Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _ ByVal fEnable As Long) As Long Private Sub DisableControls() Dim i As Integer For i = 0 To optFormat.Count - 1 'optFormat(i).Enabled = False EnableWindow optFormat(i).hwnd, 0 Next End Sub Ok, but if you disable the frame there is no need to disable the options too
-- Show quoteHide quoteThe Top Script Generator for Jordan Russell's Inno Setup - http://www.randem.com/innoscript.html Free Utilities and Code - http://www.randem.com/freesoftutil.html "Nobody" <nob***@nobody.com> wrote in message news:i5d8fi$j0g$1@speranza.aioe.org... > "Abhishek" <u***@server.com> wrote in message > news:i5cfqm$dl5$1@speranza.aioe.org... >> Hi, >> >> I have 6 radio buttons (control array) on a form, the user selects the >> option and click the OK button and there are two procedures in my code to >> enable and disable all controls until the process is complete. but when I >> disable all the radio buttons the last radio button gets automatically >> selected. I dont know why its happening. there is no other code for the >> radio buttons except in the DisableControls procedure. >> >> Private Sub DisableControls() >> Dim i As Integer >> >> For i = 0 To optFormat.Count - 1 >> optFormat(i).Enabled = False >> Next >> End Sub > > I was able to duplicate the problem with VB6+SP5, with SP6 runtime, even > if I put them on a frame. However, if I disable the frame first, then the > options, then the problem disappears. It's interesting to note that only > the last option Click event fires, not while other options are disabled. > > Another solution that I found is to use EnableWindow() API function. This > works fine whether the options are on a frame or not. > > Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _ > ByVal fEnable As Long) As Long > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > 'optFormat(i).Enabled = False > EnableWindow optFormat(i).hwnd, 0 > Next > End Sub > "Randem" <newsgro***@randem.com> wrote in message When I disable the frame, the options look enabled, not grayed out like news:OOMGFI2RLHA.2104@TK2MSFTNGP04.phx.gbl... > Ok, but if you disable the frame there is no need to disable the options > too expected, however, they don't respond to user input in either case. That is exactly what it should do and I believe is exactly what you want to
happen, the user not being able to select anything. -- Show quoteHide quoteThe Top Script Generator for Jordan Russell's Inno Setup - http://www.randem.com/innoscript.html Free Utilities and Code - http://www.randem.com/freesoftutil.html "Nobody" <nob***@nobody.com> wrote in message news:i5dvrc$93s$1@speranza.aioe.org... > "Randem" <newsgro***@randem.com> wrote in message > news:OOMGFI2RLHA.2104@TK2MSFTNGP04.phx.gbl... >> Ok, but if you disable the frame there is no need to disable the options >> too > > When I disable the frame, the options look enabled, not grayed out like > expected, however, they don't respond to user input in either case. > "Randem" <newsgro***@randem.com> wrote in message I disagree. Controls like radio buttons and check boxes should never LOOK news:%23zh%23ei7RLHA.4960@TK2MSFTNGP05.phx.gbl... > That is exactly what it should do and I believe is exactly what you want > to happen, the user not being able to select anything. like they can accept input when they can't. If you can't click them, they should be grayed out. "Jeff Johnson" wrote in message
news:i5gqg8$niv$1@news.eternal-september.org... And in the dotNet forums/newsgroups I've seen that this not making visible "Randem" <newsgro***@randem.com> wrote in message news:%23zh%23ei7RLHA.4960@TK2MSFTNGP05.phx.gbl... >> That is exactly what it should do and I believe is exactly what you want >> to happen, the user not being able to select anything. >I disagree. Controls like radio buttons and check boxes should never LOOK >like they can accept input when they can't. If you can't click them, they >should be grayed out. the disabling on a panel is seen as a feature from VB6. I give no comment on that, I understand we have the same idea about that. :-) CorOh James, Why dont you be a good boy and die?
Show quoteHide quote "Cor" <Notmyfirstn***@planet.nl> wrote in message news:%23bFsB0NSLHA.5324@TK2MSFTNGP05.phx.gbl... | "Jeff Johnson" wrote in message | news:i5gqg8$niv$1@news.eternal-september.org... "Abhishek" wrote in message news:i5ickv$3dv$1@speranza.aioe.org... I hope you will have a long live before you. >Oh James, Why dont you be a good boy and die? Cor
Show quote
Hide quote
"Cor" <Notmyfirstn***@planet.nl> wrote in message I have a program that displays a lot of information, but users don't want to news:%23bFsB0NSLHA.5324@TK2MSFTNGP05.phx.gbl... >>> That is exactly what it should do and I believe is exactly what you want >>> to happen, the user not being able to select anything. > >>I disagree. Controls like radio buttons and check boxes should never LOOK >>like they can accept input when they can't. If you can't click them, they >>should be grayed out. > > And in the dotNet forums/newsgroups I've seen that this not making visible > the disabling on a panel is seen as a feature from VB6. > > I give no comment on that, I understand we have the same idea about that. accidentally alter that data. When they do want to, they hit an Edit button. In normal view mode, it would be extremely ugly to have EVERYTHING disabled, so--in direct contrast to what I said above--there ARE times that it is okay to have unresponsive controls appear non-grayed, but I think it should be either all or nothing, which I did not make clear in my first response. So no, I don't think we have exactly the same idea about VB6's "feature." What would have been nice is if there had been a Boolean property on container objects like "PropagateDisabledStatus" so that children could be automatically disabled--or not--when disabling the main control. Jeff,
I could answer on this (I still think we agree but I cannot explain why). However, I don't because then we go to much about Net. Main thing for me is, a user should somehow be able to see in his UI that something is disabled and not think he does something wrong. Cor "Jeff Johnson" wrote in message Show quoteHide quote news:i5j29m$e3f$1@news.eternal-september.org... I have a program that displays a lot of information, but users don't want to"Cor" <Notmyfirstn***@planet.nl> wrote in message news:%23bFsB0NSLHA.5324@TK2MSFTNGP05.phx.gbl... >>> That is exactly what it should do and I believe is exactly what you want >>> to happen, the user not being able to select anything. > >>I disagree. Controls like radio buttons and check boxes should never LOOK >>like they can accept input when they can't. If you can't click them, they >>should be grayed out. > > And in the dotNet forums/newsgroups I've seen that this not making visible > the disabling on a panel is seen as a feature from VB6. > > I give no comment on that, I understand we have the same idea about that. accidentally alter that data. When they do want to, they hit an Edit button. In normal view mode, it would be extremely ugly to have EVERYTHING disabled, so--in direct contrast to what I said above--there ARE times that it is okay to have unresponsive controls appear non-grayed, but I think it should be either all or nothing, which I did not make clear in my first response. So no, I don't think we have exactly the same idea about VB6's "feature." What would have been nice is if there had been a Boolean property on container objects like "PropagateDisabledStatus" so that children could be automatically disabled--or not--when disabling the main control. "Cor" <Notmyfirstn***@planet.nl> wrote in message I agree, generally speaking. In the case of the program I mentioned it was news:%230GWy6RSLHA.2068@TK2MSFTNGP05.phx.gbl... > I could answer on this (I still think we agree but I cannot explain why). > > However, I don't because then we go to much about Net. > > Main thing for me is, a user should somehow be able to see in his UI that > something is disabled and not think he does something wrong. user education that let them know that even though the controls looked "normal," they would not accept input. Another thing--which I just now remembered since I haven't dealt with this program in a while--was that all text fields displayed as labels unless the block was in Edit mode, so there was that extra visual clue that the dropdowns*, check boxes, and radio buttons were not active. *Honestly, I might have hidden the dropdowns too and just displayed a label. Can't remember; this program got scrapped for a Web app. Oooh, ahhh, something new and shiny....
Show quote
Hide quote
"Abhishek" <u***@server.com> wrote in Don't disable the selected one ?news:i5cfqm$dl5$1@speranza.aioe.org: > Hi, > > I have 6 radio buttons (control array) on a form, the user > selects the option and click the OK button and there are > two procedures in my code to enable and disable all > controls until the process is complete. but when I disable > all the radio buttons the last radio button gets > automatically selected. I dont know why its happening. > there is no other code for the radio buttons except in the > DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub > > > anyone experienced the same behavior?
Show quote
Hide quote
"Abhishek" <u***@server.com> wrote in message If the option buttons are the last thing to be disabled then when you get news:i5cfqm$dl5$1@speranza.aioe.org... > Hi, > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub down to the last one it gets the focus. When an option button gets focus and none in the group are already selected it gets selected by default. Try re-arranging the order you disable things and make sure you do the option buttons before at least 1 other control that can get focus. Either that or set a flag that you are in the disabling routine and de-select the option button when it happens. Thanks,
i fixed it by using a flag. Show quoteHide quote "Bob Butler" <bob_butler@cox.invalid> wrote in message news:i5e03s$ppl$1@news.eternal-september.org... | | "Abhishek" <u***@server.com> wrote in message | news:i5cfqm$dl5$1@speranza.aioe.org... | > Hi, | > | > I have 6 radio buttons (control array) on a form, the user selects the | > option and click the OK button and there are two procedures in my code to | > enable and disable all controls until the process is complete. but when I | > disable all the radio buttons the last radio button gets automatically | > selected. I dont know why its happening. there is no other code for the | > radio buttons except in the DisableControls procedure. | > | > Private Sub DisableControls() | > Dim i As Integer | > | > For i = 0 To optFormat.Count - 1 | > optFormat(i).Enabled = False | > Next | > End Sub | | If the option buttons are the last thing to be disabled then when you get | down to the last one it gets the focus. When an option button gets focus | and none in the group are already selected it gets selected by default. Try | re-arranging the order you disable things and make sure you do the option | buttons before at least 1 other control that can get focus. Either that or | set a flag that you are in the disabling routine and de-select the option | button when it happens. | "Bob Butler" <bob_butler@cox.invalid> wrote in message What's interesting is that VB is the one doing that(selecting the last news:i5e03s$ppl$1@news.eternal-september.org... > If the option buttons are the last thing to be disabled then when you get > down to the last one it gets the focus. When an option button gets focus > and none in the group are already selected it gets selected by default. control because VB tries to shift the focus to the last enabled one). If you disable the buttons one by one using the API function EnableWindow() like what I showed in my first reply to this thread, then the problem doesn't happen.
Show quote
Hide quote
"Abhishek" <u***@server.com> skrev i meddelandet I always add one more than needed, and make (0) invisible.news:i5cfqm$dl5$1@speranza.aioe.org... > Hi, > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub > > > anyone experienced the same behavior? > > /Henning On 29/08/2010 18:48, Henning wrote:
Show quoteHide quote > "Abhishek"<u***@server.com> skrev i meddelandet This also allows an unselected default state :)> news:i5cfqm$dl5$1@speranza.aioe.org... >> Hi, >> >> I have 6 radio buttons (control array) on a form, the user selects the >> option and click the OK button and there are two procedures in my code to >> enable and disable all controls until the process is complete. but when I >> disable all the radio buttons the last radio button gets automatically >> selected. I dont know why its happening. there is no other code for the >> radio buttons except in the DisableControls procedure. >> >> Private Sub DisableControls() >> Dim i As Integer >> >> For i = 0 To optFormat.Count - 1 >> optFormat(i).Enabled = False >> Next >> End Sub >> >> anyone experienced the same behavior? > > I always add one more than needed, and make (0) invisible. -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.)
Show quote
Hide quote
"Dee Earley" <dee.ear***@icode.co.uk> skrev i meddelandet Yepp, that is the main reason. ;)news:%23dQSa5cSLHA.2068@TK2MSFTNGP05.phx.gbl... > On 29/08/2010 18:48, Henning wrote: >> "Abhishek"<u***@server.com> skrev i meddelandet >> news:i5cfqm$dl5$1@speranza.aioe.org... >>> Hi, >>> >>> I have 6 radio buttons (control array) on a form, the user selects the >>> option and click the OK button and there are two procedures in my code >>> to >>> enable and disable all controls until the process is complete. but when >>> I >>> disable all the radio buttons the last radio button gets automatically >>> selected. I dont know why its happening. there is no other code for the >>> radio buttons except in the DisableControls procedure. >>> >>> Private Sub DisableControls() >>> Dim i As Integer >>> >>> For i = 0 To optFormat.Count - 1 >>> optFormat(i).Enabled = False >>> Next >>> End Sub >>> >>> anyone experienced the same behavior? >> >> I always add one more than needed, and make (0) invisible. > > This also allows an unselected default state :) > > -- > Dee Earley (dee.ear***@icode.co.uk) > i-Catcher Development Team > > iCode Systems > > (Replies direct to my email address will be ignored. > Please reply to the group.) It also allows to enable/disable them from hi to lo without leaving any active. /Henning
Show quote
Hide quote
"Henning" <computer_h***@coldmail.com> wrote in message I usually prefer to have it visible and labelled "None" or something like news:i5m487$q3v$1@news.eternal-september.org... > > "Dee Earley" <dee.ear***@icode.co.uk> skrev i meddelandet > news:%23dQSa5cSLHA.2068@TK2MSFTNGP05.phx.gbl... >> On 29/08/2010 18:48, Henning wrote: >>> "Abhishek"<u***@server.com> skrev i meddelandet >>> news:i5cfqm$dl5$1@speranza.aioe.org... >>>> Hi, >>>> >>>> I have 6 radio buttons (control array) on a form, the user selects the >>>> option and click the OK button and there are two procedures in my code >>>> to >>>> enable and disable all controls until the process is complete. but when >>>> I >>>> disable all the radio buttons the last radio button gets automatically >>>> selected. I dont know why its happening. there is no other code for the >>>> radio buttons except in the DisableControls procedure. >>>> >>>> Private Sub DisableControls() >>>> Dim i As Integer >>>> >>>> For i = 0 To optFormat.Count - 1 >>>> optFormat(i).Enabled = False >>>> Next >>>> End Sub >>>> >>>> anyone experienced the same behavior? >>> >>> I always add one more than needed, and make (0) invisible. >> >> This also allows an unselected default state :) that > Yepp, that is the main reason. ;) only if the invisible one has Value=True or none of them get the focus > > It also allows to enable/disable them from hi to lo without leaving any > active. during the disabling process On 01/09/2010 19:13, Bob Butler wrote:
Show quoteHide quote > "Henning" <computer_h***@coldmail.com> wrote in message The only point I use it is in the wizard where an choice is required but > news:i5m487$q3v$1@news.eternal-september.org... >> "Dee Earley" <dee.ear***@icode.co.uk> skrev i meddelandet >> news:%23dQSa5cSLHA.2068@TK2MSFTNGP05.phx.gbl... >>> On 29/08/2010 18:48, Henning wrote: >>>> "Abhishek"<u***@server.com> skrev i meddelandet >>>> news:i5cfqm$dl5$1@speranza.aioe.org... >>>>> when I disable all the radio buttons the last radio button >>>>> gets automatically selected. >>>> >>>> I always add one more than needed, and make (0) invisible. >>> >>> This also allows an unselected default state :) > > I usually prefer to have it visible and labelled "None" or something > like that "none" is nonsensical. The hidden one is selected initially but is hidden when any other item is selected so it can't re get focus. -- Dee Earley (dee.ear***@icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) Abhishek wrote:
Show quoteHide quote > Hi, Interesting. I was able to recreated the issue under VB6+SP6 and using a > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub > > > anyone experienced the same behavior? timer control to simulate some code execution. One way I fixed it was by disabling all the controls but your "execute" button as last. Private Sub cmdExecute_Click() Call EnableRadioButtons(False) Me.cmdRun.Enabled = False End Sub Alternatively you can disable all the radio buttons, but the one that's checked last. Private Sub EnableRadioButtons(status As Boolean) Dim I As Integer Dim J As Integer If (status = True) Then For I = 0 To optFormat.Count - 1 optFormat(I).Enabled = True Next Else For I = 0 To optFormat.Count - 1 If (optFormat(I).Value = True) Then J = I Else optFormat(I).Enabled = False End If Next optFormat(J).Enabled = False End If End Sub Interesting issue. It has to do with the control's active focus. -Nando I use this routine to enable and disable controls in a container. You
could modify it to the .Visible property instead of the .Enabled and ..Forecolor properties. I use this when I have a "master" checkbox, which in turn, enables or disables a Frame and it's child controls. Also, Labels are greyed so give the appearance that the Frame, and all it's controls, are disabled. You can add other controls types as required. Might be a starting point... '--------------------------------------------------------------------------------------- ' Procedure : SetChildrenEnabled ' DateTime : 10/02/2010 12:14 ' Author : Andrew ' Purpose : Enable or Disable controls in a Frame ' Arguments : Obj: the container Frame, State to set, Set Container Frame enabled also? ' Returns : none '--------------------------------------------------------------------------------------- ' Public Sub SetChildrenEnabled(obj As Object, State As Boolean, Optional MeToo As Boolean) Dim Ctl As Control On Local Error Resume Next For Each Ctl In obj.Parent.Controls If Ctl.Container Is obj Then If TypeOf Ctl Is Label Then If State Then Ctl.ForeColor = QBColor(0) Else Ctl.ForeColor = QBColor(8) End If ElseIf TypeOf Ctl Is Line Then If State Then Ctl.BorderColor = QBColor(0) Else Ctl.BorderColor = QBColor(8) End If ElseIf TypeOf Ctl Is Shape Then If State Then Ctl.BorderColor = QBColor(0) Else Ctl.BorderColor = QBColor(8) End If Else Ctl.Enabled = State End If If MeToo Then obj.Enabled = State End If End If Next Ctl Err.Number = 0 End Sub Andrew DynoLog Dynamometer Australia On 29/08/2010 12:14 PM, Abhishek wrote: Show quoteHide quote > Hi, > > I have 6 radio buttons (control array) on a form, the user selects the > option and click the OK button and there are two procedures in my code to > enable and disable all controls until the process is complete. but when I > disable all the radio buttons the last radio button gets automatically > selected. I dont know why its happening. there is no other code for the > radio buttons except in the DisableControls procedure. > > Private Sub DisableControls() > Dim i As Integer > > For i = 0 To optFormat.Count - 1 > optFormat(i).Enabled = False > Next > End Sub > > > anyone experienced the same behavior? > > |
|||||||||||||||||||||||