Exploring the TimeCheck Application (Part 5)

Someone reported a problem with last week’s post (see Exploring the TimeCheck Application (Part 4)). It seems that frmReportConfigure has an accessibility problem. Even though the form doesn’t have any functionality built into it just yet, you can compile and run the application to see the problem. Try pressing Tab to move between the radio buttons. You’ll find that you can’t use the Tab key to select Project Report or Totals Report when User Report is selected. The same thing happens with the other selections. It’s impossible to use the Tab to move between the radio buttons even though the application is supposed to make each of the radio buttons a tab stop. Now, imagine that the Tab is your only means of navigating the form (or simply that you’re used to using the keyboard and using the mouse is normally too time consuming to meet your needs).

The problem is that pressing Tab after User Report has the focus selects Selected User. Press Tab again and you move to User’s Project, then to User’s Task, and then back to Close. What’s happening? At first I thought a change in tab order (TabIndex property setting) might do the trick, but that’s not the case. Then I thought about making just the radio buttons tab stops by setting the TabStop property on the ComboBox controls to False. However, not only does this break accessibility, but it didn’t solve the radio button problem. In fact, I spent several hours considering various solutions to the problem. None of the configuration changes I made corrected the problem. If someone has a configuration solution to the problem, please write me at John@JohnMuellerBooks.com.

I finally created a coded fix for the problem. When the user presses Tab on the Close button, the focus should always go to User Report. Likewise, when the user presses Tab for an unchecked radio button, the focus should go to the next radio button in line. When a radio button is checked, the focus should go to the controls associated with the radio button, and then move to the next radio button after the last control. With this in mind, I fixed the accessibility issue on this forum using the following code.

private void btnClose_Leave(object sender, EventArgs e)
{
   // Give the User Report radio button focus.
   rbUser.Focus();
}
 
private void rbUser_Leave(object sender, EventArgs e)
{
   // When User Report isn't checked, then give the focus
   // to the Project Report radio button.
   if (!rbUser.Checked)
      rbProject.Focus();
}
 
private void cbUserTask_Leave(object sender, EventArgs e)
{
   // Give the Project Report radio button focus.
   rbProject.Focus();
}
 
private void rbProject_Leave(object sender, EventArgs e)
{
   // When Project Report isn't checked, then give the focus
   // to the Totals Report radio button.
   if (!rbProject.Checked)
      rbTotals.Focus();
}
 
private void cbSelectedProject_Leave(object sender, EventArgs e)
{
   // Give the Totals Report radio button focus.
   rbTotals.Focus();
}

I appreciate readers keeping me on my toes, especially when it comes to accessibility issues. Next week, we’ll move on to building the database elements for this application. In the meantime, don’t be afraid to write with your questions and comments. You can read the next post in this series at Exploring the TimeCheck Application (Part 6).