Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6721941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:23:19+00:00 2026-05-26T09:23:19+00:00

I have a really strange problem. I have multiple TextBoxes for username/passwords, and a

  • 0

I have a really strange problem.
I have multiple TextBoxes for username/passwords, and a CheckBox beside every user/pass group. When user clicks on the CheckBox, and if he checked it, the username and password TextBox beside it become enabled and focus is set to username TextBox. If user unchecked the CheckBox the TextBoxes beside it become disabled. However the border of one TextBox stays different than other disabled TextBoxes.

See:

http://img545.imageshack.us/img545/1944/textbox.png

I’ve thought it was a focus problem, so I’ve changed the code – when user unchecks the CheckBox it first focuses on some other element on the form and then disables it, but it still does the same thing.
Any ideas on what could cause the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:23:19+00:00Added an answer on May 26, 2026 at 9:23 am

    So far as I can tell, this is a bug in the way the system is rendering the control’s disabled state. I’ve created the following code to simulate this issue. The code is a bit verbose but I made it so in order easily understand the logic flow.

    I created a form, with :
    4 textboxes named txtBox1, txtBox2, txtBox3 and txtBox4
    4 checkboxes named chkBox1, chkBox2, chkBox3 and chkBox4

    Set the Enabled property of each textbox to False (I did this at design time)

        private void Form1_Load(object sender, EventArgs e) {
            chkBox1.CheckedChanged += chkBox_CheckedChanged;
            chkBox2.CheckedChanged += chkBox_CheckedChanged;
            chkBox3.CheckedChanged += chkBox_CheckedChanged;
            chkBox4.CheckedChanged += chkBox_CheckedChanged;
        }
    
        private void chkBox_CheckedChanged(object sender, EventArgs e) {
            var chkBox = ((CheckBox)sender);
            var controlSet = chkBox.Name.Substring(6,1);
            var txtName = "txtBox" + controlSet;
    
            foreach (var txtBox in Controls.Cast<object>().Where(ctl => ((Control)ctl).Name == txtName).Select(ctl => ((TextBox)ctl))) {
                if (chkBox.Checked) {
                    txtBox.Enabled = true;
                    txtBox.Focus();
                }
                else {
                    //The checkbox stole the focuse when it was clicked, so no need to change.
                    txtBox.Enabled = false;
                }
            }
        }
    

    Now if you execute this code, you can check the checkboxes to enable the textbox with the same name prefix (1, 2, 3 or 4). This also sets the focus to the Textbox. Now, if you disable a Textbox that has the focus, it shows up differently than other disabled Textboxes.

    I tried all kinds of Refresh, Invalidate, etc.. on the controls and Form itself to no avail.

    UPDATE

    So I found a hack that seems to work. If you set the borderstyle of the textbox to ‘None’ before disabling, and then reset it afterwards, the odd outline effect doesn’t happen.

        var borderStyle = txtBox.BorderStyle;
        txtBox.BorderStyle = BorderStyle.None;
        txtBox.Enabled = false;
        txtBox.BorderStyle = borderStyle;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've come across a really strange problem. I have written a simple Deck class
I am having some strange problem and its really frustating me. I have a
I have a really strange problem with the standard logging module used in django
I have this really strange problem where my entity framework query isn't enumerating correctly.
So this is a really strange problem. I have a Java app that acts
This is a really strange problem I'm seeing in my app. I have an
I have a really strange problem that I can't explain and fix, it is
I have a really strange problem, following attribute of a jsp tag <custom:tag onclick=addBid('<%=
I have a really strange problem with CMSMS - why the hell this is
This is really a strange problem. I have a tab bar controller with 5

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.