Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Form Causesvalidation property

Form Causesvalidation property

Scheduled Pinned Locked Moved C#
questioncsharphelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zapss
    wrote on last edited by
    #1

    Hello, Iam new to c# My Problem is something like this. Create a sample windows application, having 2 textboxes & a command button Set the forms controlbox property to True Write validation event for the 2 textboxes private void txtpassword_Validating(object sender,System.ComponentModel.CancelEventArgs e) if (txtempno.Text=="" | txtpassword.Text=="") { MessageBox.Show("Please Enter User Id and password","Invalid Data",MessageBoxButtons.OKCancel); e.Cancel = true; } while running the application when the user clicks the button1 the focus is still in 1 of the textboxes, the validation event of the textboxes still fire. Same is the case when the user clicks the X button on the control box. i.e validation event is fired and form is not closed Form Causesvalidation property aslo set flase. if i write the code in the Form1_closing event then also the problem is not being solved. This is because the validation event of the textboxes is fired first so the execution never reaches the Form1_closing event. i need to provide this funcationality in my application,How can i do this?

    J 1 Reply Last reply
    0
    • Z Zapss

      Hello, Iam new to c# My Problem is something like this. Create a sample windows application, having 2 textboxes & a command button Set the forms controlbox property to True Write validation event for the 2 textboxes private void txtpassword_Validating(object sender,System.ComponentModel.CancelEventArgs e) if (txtempno.Text=="" | txtpassword.Text=="") { MessageBox.Show("Please Enter User Id and password","Invalid Data",MessageBoxButtons.OKCancel); e.Cancel = true; } while running the application when the user clicks the button1 the focus is still in 1 of the textboxes, the validation event of the textboxes still fire. Same is the case when the user clicks the X button on the control box. i.e validation event is fired and form is not closed Form Causesvalidation property aslo set flase. if i write the code in the Form1_closing event then also the problem is not being solved. This is because the validation event of the textboxes is fired first so the execution never reaches the Form1_closing event. i need to provide this funcationality in my application,How can i do this?

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      Not a 100% sure this will solve your problem, as I dont really understand the question, but just in case its a simple as: boolean or || bitwise or | if (txtempno.Text=="" | txtpassword.Text=="") should read if (txtempno.Text=="" || txtpassword.Text=="")

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups