i have custom controls inside a page view control. the custom control binds data on the load event. the problem is whenever a control is being added to the page view the load event of the control is being fired immediately inside the constructor of the control which holds the page view control. as a result it throws exception when trying to access data.
the following code is the component initialization code which is called from the constructor of the control which holds the page view control
here ctlManageBank1 is my custom control which loads data on its load event. the load event is being called immediately after the control is added to the page object of page view control (bold line).
if i use a tab control instead of a page view control everything goes fine. the load event fires at the time of showing the control, not inside the constructor.
the following code is the component initialization code which is called from the constructor of the control which holds the page view control
private
void
InitializeComponent()
{
this
.rdpvAppCodeFiles =
new
Telerik.WinControls.UI.RadPageView();
this
.rdpvpBank =
new
Telerik.WinControls.UI.RadPageViewPage();
this
.ctlManageBank1 =
new
CRS.Client.App.Documents.CodeFiles.ApplicationCodeFiles.BankDocuments.ctlManageBank();
((System.ComponentModel.ISupportInitialize)(
this
.rdpvAppCodeFiles)).BeginInit();
this
.rdpvAppCodeFiles.SuspendLayout();
this
.rdpvpBank.SuspendLayout();
this
.SuspendLayout();
//
// rdpvAppCodeFiles
//
this
.rdpvAppCodeFiles.Controls.Add(
this
.rdpvpBank);
this
.rdpvAppCodeFiles.Dock = System.Windows.Forms.DockStyle.Fill;
this
.rdpvAppCodeFiles.Location =
new
System.Drawing.Point(0, 0);
this
.rdpvAppCodeFiles.Name =
"rdpvAppCodeFiles"
;
this
.rdpvAppCodeFiles.SelectedPage =
this
.rdpvpBank;
this
.rdpvAppCodeFiles.Size =
new
System.Drawing.Size(846, 502);
this
.rdpvAppCodeFiles.TabIndex = 1;
this
.rdpvAppCodeFiles.Text =
"radPageView1"
;
this
.rdpvAppCodeFiles.SelectedPageChanged +=
new
System.EventHandler(
this
.rdpvAppCodeFiles_SelectedPageChanged);
((Telerik.WinControls.UI.RadPageViewStripElement)(
this
.rdpvAppCodeFiles.GetChildAt(0))).StripAlignment = Telerik.WinControls.UI.StripViewAlignment.Right;
((Telerik.WinControls.UI.RadPageViewStripElement)(
this
.rdpvAppCodeFiles.GetChildAt(0))).ItemContentOrientation = Telerik.WinControls.UI.PageViewContentOrientation.Horizontal;
//
// rdpvpBank
//
this
.rdpvpBank.Controls.Add(
this
.ctlManageBank1);
this
.rdpvpBank.Location =
new
System.Drawing.Point(10, 10);
this
.rdpvpBank.Name =
"rdpvpBank"
;
this
.rdpvpBank.Size =
new
System.Drawing.Size(750, 481);
this
.rdpvpBank.Text =
"Bank"
;
//
// ctlManageBank1
//
this
.ctlManageBank1.CurrentMode = CRS.Client.Automation.Documents.ctlDocumentUIBase.OperationMode.None;
this
.ctlManageBank1.Dock = System.Windows.Forms.DockStyle.Fill;
this
.ctlManageBank1.Document =
null
;
this
.ctlManageBank1.Location =
new
System.Drawing.Point(0, 0);
this
.ctlManageBank1.Name =
"ctlManageBank1"
;
this
.ctlManageBank1.Size =
new
System.Drawing.Size(750, 481);
this
.ctlManageBank1.TabIndex = 0;
// ctlApplicationCodeFilesSwitchBoard
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.Controls.Add(
this
.rdpvAppCodeFiles);
this
.Name =
"ctlApplicationCodeFilesSwitchBoard"
;
this
.Size =
new
System.Drawing.Size(846, 502);
((System.ComponentModel.ISupportInitialize)(
this
.rdpvAppCodeFiles)).EndInit();
this
.rdpvAppCodeFiles.ResumeLayout(
false
);
this
.rdpvpBank.ResumeLayout(
false
);
this
.ResumeLayout(
false
);
}
here ctlManageBank1 is my custom control which loads data on its load event. the load event is being called immediately after the control is added to the page object of page view control (bold line).
if i use a tab control instead of a page view control everything goes fine. the load event fires at the time of showing the control, not inside the constructor.