To reproduce:
1. Have a scheduler grouped by resource
2. On a button click call its PrintPreview method
3. Open the print settings dialog
4. Select Weekly Style
5. Select Grouped by: Resource
6. Select Two pages per week
at this point, exception is thrown
Workaround:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
AddScheduler();
radScheduler1.PrintSettingsDialogFactory = new MyFactory();
}
private void radButton1_Click(object sender, EventArgs e)
{
radScheduler1.PrintPreview();
}
class MySchedulerPrintSettingsDialogFactory : SchedulerPrintSettingsDialog
{
SchedulerPrintStyleSettings userControl;
RadDropDownList groupBy;
RadDropDownList twoPagesPerView;
RadDropDownList printStyle;
public MySchedulerPrintSettingsDialogFactory(RadPrintDocument document)
: base(document) { }
protected override Control CreateFormatControl()
{
userControl = base.CreateFormatControl() as SchedulerPrintStyleSettings;
RadGroupBox groupBox = userControl.Controls["groupBoxStyleSettings"] as RadGroupBox;
groupBy = groupBox.Controls["dropDownGroupBy"] as RadDropDownList;
groupBy.SelectedIndexChanged += groupBy_SelectedIndexChanged;
twoPagesPerView = groupBox.Controls["dropDownLayout"] as RadDropDownList;
twoPagesPerView.SelectedIndexChanging += twoPagesPerView_SelectedIndexChanging;
RadGroupBox groupBoxMain = userControl.Controls["groupBoxPrintStyle"] as RadGroupBox;
printStyle = groupBoxMain.Controls["dropDownPrintStyle"] as RadDropDownList;
printStyle.SelectedValueChanged += printStyle_SelectedValueChanged;
return userControl;
}
void printStyle_SelectedValueChanged(object sender, EventArgs e)
{
if (printStyle.SelectedItem.Text == "Weekly Style")
{
twoPagesPerView.SelectedItem = twoPagesPerView.Items[0];
}
}
void twoPagesPerView_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
{
if (groupBy.SelectedItem.Text == "Resource" && e.Position == 1)
{
e.Cancel = true;
RadMessageBox.Show("Two pages per view is not supported in GroupBy:Resource mode");
}
}
void groupBy_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
if (groupBy.Items[e.Position].Text == "Resource")
{
twoPagesPerView.SelectedItem = twoPagesPerView.Items[0];
}
}
}
class MyFactory : IPrintSettingsDialogFactory
{
public Form CreateDialog(RadPrintDocument document)
{
return new MySchedulerPrintSettingsDialogFactory(document);
}
}