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 8175813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:54:41+00:00 2026-06-06T22:54:41+00:00

Im currently facing the problem that when i try to set focus on some

  • 0

Im currently facing the problem that when i try to set focus on some control (textBox), nothing happens, maybe i just overlooked something.(somewhere i found that focus is “low-level” method and that select() should be used instead, however, it doesnt work as well)

From form Login, i launch new instance of EncryptPSW form

private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
        EncryptPSW ePSW = new EncryptPSW();
        ePSW.setOsLog(false, this);
        ePSW.ShowDialog();        
    }

On Button(which is located on EncryptPSW form ) click event i call fill method

public void fill()
    {
        if (textBoxPSW.Text.Length == 8)//psw has to be 8 chars long
        {
            if (save)//determinating whether save or fetch of data should be done
            { login.launchSave(textBoxPSW.Text,this); }
            else { login.launchOpen(textBoxPSW.Text,this); }
        }
        else { MessageBox.Show("The password must contain 8 characters");}
    }

Which launches either save or open method from Login (my problem is just with open, since during save i dont need to do anything with Focus)

public void launchOpen(string psw,EncryptPSW ePSW)
    {

        ePSW.Close();
        Encryptor.DecryptFile("loggin.bin", psw, this); //decrypting data and setting textBoxes Text property into the fetched ones
        setFocus();

    }

After all the work is done, setFocus() should be called in order to set focus and other properties.

public void setFocus()
    {
        textBoxDatabase.Focus();
        textBoxDatabase.SelectionStart = textBoxDatabase.TextLength - 1;
        textBoxDatabase.SelectionLength = 0;
    }

I tried so many different ways, like:

Calling setFocus() from within EncryptPSW_FormClosed
Calling whole open process after the EncryptPSW is closed (from within EncryptPSW_FormClosed)
and many more, however i dont remember it all.

In the case of Form_Closed the weird thing is, that when i tried to show a message box from there instead of setting focus (just to see where the problem might be), it’s showed before the EncryptPSW form is closed.

My only guess about this is that the instance of EncryptPSW is somehow blocking Login form and it’s controls

I hoped i described my problem well enough and that it makes at least a bit of sense ;]

Thanks in advance,

Regards,

Releis

  • 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-06-06T22:54:43+00:00Added an answer on June 6, 2026 at 10:54 pm

    Since the textbox is in the login form, and you are opening the EcryptPWS from it as a dialog (child), your login form will not be able to set focus to anything. You will need to set focus after it is closed. You can do this:

    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
        using(EncryptPSW ePSW = new EncryptPSW())
        {
           ePSW.setOsLog(false, this);
           if (ePSW.ShowDialog() == DialogResult.OK)
           {
               textBoxDatabase.Focus(); 
           }
        }
    } 
    
    public void launchOpen(string psw,EncryptPSW ePSW) 
    { 
        ePSW.DialogResult = DialogResult.OK;
        ePSW.Close(); 
        Encryptor.DecryptFile("loggin.bin", psw, this); //decrypting data and setting textBoxes Text property into the fetched ones 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently facing the problem that I want to serve static content via a
I am currently facing a problem that is concerning the google search, curl and
I'm currently facing this problem with ruby on rails 3, devise and facebook oauth.
I'm currently facing a weird problem while executing a command from my bash script.
I am currently working on a Wordpress blog installation. Problem i am facing is
I am currently facing the conundrum that when I rotate my device, the view
Currently I am facing issues, that the java melody statistics running for a grails
I'm facing a problem that's really strange. It's in every browser. Everything is working
I'm currently facing a problem I haven't been able to solve myself. Basically what
I am currently facing a serious problem. I use the standard django admin interface

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.