This is a migrated thread and some comments may be shown as answers.

PageViewPage - ErrorProvider.SetError()

1 Answer 56 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Doug
Top achievements
Rank 1
Doug asked on 20 Aug 2013, 07:38 PM
I'm open to alternatives.

I would like to use the ErrorProvider to set error text on the tabs of PageViewPages.  Can that be done?

(As an alternative, I can modify the text on the tab to indicate that the page has errors on it.)

Thank you,
Gary

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Aug 2013, 01:47 PM
Hello Gary,

Thank you for contacting Telerik Support.

Please refer to the following code example demonstrating how to manage errorProvider for each RadPageViewPage:
public Form1()
{
    InitializeComponent();
     
    errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;
 
    this.radPageView1.SelectedPageChanging += radPageView1_SelectedPageChanging;
    this.radPageView1.ViewMode = PageViewMode.Strip;
}
 
private void radPageView1_SelectedPageChanging(object sender, Telerik.WinControls.UI.RadPageViewCancelEventArgs e)
{
    RadPageView pageView = sender as RadPageView;
    if (!ValidatePage(pageView.SelectedPage))
    {
        int index = this.radPageView1.Pages.IndexOf(this.radPageView1.SelectedPage);
        int X = ((RadPageViewStripElement)this.radPageView1.ViewElement).Children[0].Children[0].Children[index].BoundingRectangle.X;
 
        e.Cancel = true;
        errorProvider1.SetIconAlignment(pageView.SelectedPage, ErrorIconAlignment.TopLeft);
        errorProvider1.SetIconPadding(pageView.SelectedPage, -X - 50);
        errorProvider1.SetError(pageView.SelectedPage, string.Format("Invalid {0}", pageView.SelectedPage.Text));
    }
    else
    {
        errorProvider1.SetError(pageView.SelectedPage, string.Empty);
    }
}
 
private bool ValidatePage(RadPageViewPage radPageViewPage)
{
    switch (radPageViewPage.Text)
    {
        case "radPageViewPage1":
            if (radTextBox1.Text == string.Empty)
            {
                return false;
            }
            return true;
        case "radPageViewPage2":
            if (radToggleButton1.ToggleState == Telerik.WinControls.Enumerations.ToggleState.Off)
            {
                return false;
            }
            return true;
        case "radPageViewPage3":
            return false;
 
        default:
            return true;
    }
}

Note that positioning the .NET errorProvider icon is not quite customizable, so I were forced to use icon padding in order to position correctly the exclamation mark under the middle of each RadPageViewPage header.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
PageView
Asked by
Doug
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or