?
Solved

Tab Control - disable button when switching tabs.

Posted on 2005-04-01
2
Medium Priority
?
552 Views
Last Modified: 2009-12-16
Hi,

I have created a windows form with a tab control.  Each tab control has a number of textboxes which are filled with data using databind.  I have an "Apply" button which is disabled until any of the text is changed in the textboxes (using the .TextChanged handler).  The problem is that when I click another tab the TextChanged handler is executed and the "Apply" button is enabled even though no text has been changed (see code example below).  

Private Sub TextBox_Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbCompanyName.TextChanged
    Me.btnApply.Enabled = True
End Sub

Anybody any ideas how to keep the apply button disabled if nothing was changed on the first tab?

Thanks

Marcus
0
Comment
Question by:marcus_d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
stripathi earned 2000 total points
ID: 13745178
Marcus,

You may want to move this code to the lostfocus event which will only happen if user enters the box and leaves it. This may solve this changed event issues as this will be fired even if you have any databinding code in TabChanged event. So when you click on a tab, that code will make Changed event to trigger with effect of enabling btnApply to enable.

Sal.
0
 

Author Comment

by:marcus_d
ID: 13751609
Thanks for your response.  I've taken your advice and used the lostfocus handler to enable the apply button.  Because I only wanted the apply button to be enabled if text had been changed I used the following procedure :-

Private Sub CompanyName_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbCompanyName.LostFocus
   If Me.tbCompanyName.Text <> strCompanyName Then
      Me.btnApply.Enabled = True
   End If
End Sub
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question