Toolstripbutton not validating textbox.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Toolstripbutton not validating textbox.

  1. #1
    Join Date
    Mar 2009
    Posts
    67

    Question Toolstripbutton not validating textbox.

    I have a textbox, a standard button and a toolstrip containing a couple of buttons. In the validating event of the textbox i coded to check whether it is blank. If yes then it shows a message 'Enter Value'. When the standard button is clicked while the textbox is empty, it's validating properly and showing the message but when the toolstripbutton is clicked it's not not validating the textbox and no message is being shown. It seems that I gotto write the validation code explicitly in the toolstripbutton_click event which is too troublesome when there are multiple textboxes and toolstripbuttons on a single form. What I want to know is whether the textbox_validating can be fired while the toolstripbutton is clicked?
    Handling toolstrips is really a headache.
    Please help. I'm badly in need of it. Regards.

  2. #2
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    The ToolStrip is not a Control, it is a Component (it appears in the component tray at the bottom of the form). Components do not trigger validation (they do not have the CauseValidation property that controls have).

    An event being a Sub as any other, you can call it. The solution is thus to call the validation event procedure from the Click of your ToolStripButton.

    Code:
      Private Sub ToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        TextBox1_Validating(Nothing, Nothing)
      End Sub
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

  3. #3
    Join Date
    Mar 2009
    Posts
    67

    Thumbs up

    Or else u can write either of the two in toolstripbutton click event:
    Code:
    DataGridView.EndEdit()
    Or

    Code:
    Me.Validate()

Similar Threads

  1. Replies: 3
    Last Post: 09-25-2009, 08:19 AM
  2. Replies: 0
    Last Post: 02-10-2009, 05:09 AM
  3. Create User Wizard
    By saquib189 in forum ASP.NET
    Replies: 1
    Last Post: 09-19-2008, 02:57 PM
  4. Replies: 1
    Last Post: 07-07-2006, 06:37 AM
  5. Validating textbox only when checkbox is cheked
    By saibaba111 in forum ASP.NET
    Replies: 2
    Last Post: 05-08-2006, 09:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center