event control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siddhanta
    New Member
    • Oct 2009
    • 33

    #1

    event control

    hi,
    i m new in c sharp. I m working in a project in which there are 4 textbox , which are to filled serially. If the user filled the wrong value in first textbox , a message should be displayed and the control should remain in the same textbox. or in other words user should be forced to fill the boxes serially. i hope i explained the problem.
    so,plz, help me in getting out of this prob.
    thanx
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Use the .Enabled property to disable the other textboxes
    .Enabled = false;

    When the user has given a proper answer to the first textbox you can disable it, enable the second and use the .Focus property to put the cursor in that box.

    Comment

    • siddhanta
      New Member
      • Oct 2009
      • 33

      #3
      .focus

      thanx for the previous reply.
      but using .Focus(textbox2 .focus in textbox1) gives error Error "Cannot assign to 'Focus' because it is a 'method group' "

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Right.
        It is a method. The error tells you this.
        Methods take parameters within parentheses.
        Code:
        textbox2.focus();

        Comment

        • siddhanta
          New Member
          • Oct 2009
          • 33

          #5
          textbox movin prob

          hi,
          i have 4 textboxes in my project.
          if a wrong entry is made in a textbox, then as soon as i move to nexttextbox a error box is displayed. and all the entries should be made serially.
          i used enabled key bt in that case mouse cant be used.
          then i used foll code:
          Code:
          private void textBox1_Leave(object sender, EventArgs e)
                  {
                      
                          text1();               
                          label6.Visible = false;
                          button4.Enabled = true;
          }
          public void text1()
                  {
                      if (textBox1.Text == "")
                      {
                           System.Windows.Forms.DialogResult result = MessageBox.Show(this, "Enter tttValue between[ 1 to 3000]", "Start Value error", MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
                          if (result == System.Windows.Forms.DialogResult.OK)
                              textBox1.Focus();             
                                    return;
                      }            
                          s = float.Parse(textBox1.Text);
                          if (!(s > 0 && s < 3000))
                          {
                                                  System.Windows.Forms.DialogResult result = MessageBox.Show(this, "Enter Value between[ 1 to 3000]", "Start Value error", MessageBoxButtons.OK,
                              MessageBoxIcon.Error);
                              if (result == System.Windows.Forms.DialogResult.OK)
                                  textBox1.Focus();                    
                              return;
                          }
                                     
                  }
          but in this case if i move from textbox2 to textbox1 its not allowing me due to leave func.
          so is there any other way i can do that

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

            Comment

            • tlhintoq
              Recognized Expert Specialist
              • Mar 2008
              • 3532

              #7
              if i move from textbox2 to textbox1 its not allowing me due to leave func.
              and all the entries should be made serially.
              Well which is it? If all entries are to be made in sequence then you aren't allowing people to back up from textbox2 to textbox1.

              if you are allowing people to do so but only under certain conditions then you need to check for those conditions and if they are met, then re-enable textbox1.

              Comment

              • tlhintoq
                Recognized Expert Specialist
                • Mar 2008
                • 3532

                #8
                Also... You already a thread started for this question. There was no reason to start a second one for the same issue/problem. I have merged the two threads. In the future please keep to the basic guide lines of "One thread per issue/One issue per thread."

                Comment

                Working...