|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Bug in Radio Button (or weird feature)everybody a "Heads Up". I spent three days doing trial and error until I found a work around. I created a user control with a text box and two radio buttons. The text box has the TabStop = True, and both radio buttons have TabStop = False. The radio buttons are set to false so that a Tab (or captured Enter) may tab to the next control. The appropriate radio button is set depending if the text is negative or non-negative. Here's the bugs: 1) Setting the TabStop property for the radio buttons in the user control did not always hold the False value. If you go into the designer code, there is no override code for setting the property. The control will use its default of True. 2) Inserting the TabStop property setting in the design code would also not stay. Very frustrating. There was much cursing. 3) Here's the Rosetta stone for the first two problems ... If you programmatically change the checked radio button, the TabStop for the radio button is apparently set back to True! Perhaps Microsoft considers this to be a "feature", but I can't imagine why. The workaround was to simply set both radio buttons back to false, immediately after I changed the checked value. This seems to work, although a bit heavy handed on the programming side. If m_dblCode > 0 Then OptCheck.Checked = True ElseIf m_dblCode < 0 Then optDebit.Checked = True Else If m_IsCheckDefault Then OptCheck.Checked = True Else optDebit.Checked = True End If End If optDebit.TabStop = False OptCheck.TabStop = False According to the documentation the default is false, not true.
Also, the very first thing that the documentation says about the property might gives a clue to why you have trouble using it: "This property supports the .NET Framework infrastructure and is not intended to be used directly from your code." Shane wrote: Show quoteHide quote > I think that I found a bug in the Radio Button, and I wanted to give > everybody a "Heads Up". I spent three days doing trial and error until > I found a work around. > > I created a user control with a text box and two radio buttons. The > text box has the TabStop = True, and both radio buttons have TabStop = > False. The radio buttons are set to false so that a Tab (or captured > Enter) may tab to the next control. The appropriate radio button is set > depending if the text is negative or non-negative. > > Here's the bugs: > 1) Setting the TabStop property for the radio buttons in the user > control did not always hold the False value. If you go into the > designer code, there is no override code for setting the property. The > control will use its default of True. > > 2) Inserting the TabStop property setting in the design code would also > not stay. Very frustrating. There was much cursing. > > 3) Here's the Rosetta stone for the first two problems ... If you > programmatically change the checked radio button, the TabStop for the > radio button is apparently set back to True! Perhaps Microsoft > considers this to be a "feature", but I can't imagine why. > > The workaround was to simply set both radio buttons back to false, > immediately after I changed the checked value. This seems to work, > although a bit heavy handed on the programming side. > > If m_dblCode > 0 Then > OptCheck.Checked = True > ElseIf m_dblCode < 0 Then > optDebit.Checked = True > Else > If m_IsCheckDefault Then > OptCheck.Checked = True > Else > optDebit.Checked = True > End If > End If > optDebit.TabStop = False > OptCheck.TabStop = False > |
|||||||||||||||||||||||