We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Validating & Control Focus

Thread ID:





13928 May 13,2004 01:55 PM UTC May 18,2004 04:19 PM UTC WinForms 1
Tags: FAQ
Asked On May 13, 2004 01:55 PM UTC

Hi, I have implemented a form using a TabControl with 5 TabPages. On one page, I have a number of controls, i.e., ComboBoxes, RadioButtons, NumericUpDowns, etc. I want to validate the data entered by the user into these controls and at the same time allow the user to cancel the form if he wishes. To implement this, I copied some sample code: private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e) { tabControl1.TabPages[tabControl1.SelectedIndex].Focus(); tabControl1.TabPages[tabControl1.SelectedIndex].CausesValidation = true; } private void tpSchedule_Validating(object sender, CancelEventArgs e) { bool bValid = true; if ((string)cboSchedule.SelectedItem == "Weekly") { if (cboRunOnDOW.SelectedItem.ToString() == "") bValid = false; } } My problem is that the TabPage always has the focus and won''t allow the Cancel button push to be handled. If I remove the first line of the SelectedIndexChanged() event handler, the Cancel button push is handled, but then the validation stuff is never invoked. Does anyone know how to fix this? Thanks, Royce

Administrator [Syncfusion]
Replied On May 18, 2004 04:19 PM UTC

Did you try setting CausesValidation to false on the Cancel button? It should then prevent validation of the controls. -Praveen Syncfusion


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon