scampercat

scampercat

  • NA
  • 189
  • 0

C# 2010 textbox and submit buttons

Jun 17 2013 6:22 PM
In a C# 2010 desktop application, I would like to use the following code when
the user is  selecting  a  file in a specified directory path:  

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            dialog.InitialDirectory = "C:";
            dialog.Title = "Select a text file";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                strPKGID = dialog.FileName;
            }


I would like to use the above code in the following situations:
1. When the text box containing the file location loses focus and
2. When a submit button on the form is clicked.

Would you show me code for losing focus on the textbox and clicking the submit button?

Answers (3)