TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sammi taylor
NA
19
0
Pass ID from usercontrol1 to usercontrol2
Apr 21 2015 7:14 PM
I have 2 usercontrols in 1 parent form. I created event handler in UserControl1, added it to the ParentForm. From there, I need to pass id to Usercontrol2 to save it.
UserControl1=MainCaseUserControl
Div
//Create delegate for my event
public
delegate
void
CaseUpdatedEventHander
(
object
sender,
CaseUpdatedEventArgs
e);
//add an event of the delegate type
public
event
CaseUpdatedEventHander
CaseUpdated;
protected
void
OnCaseUpdated(
int
? ID) {
CaseUpdatedEventArgs
e =
new
CaseUpdatedEventArgs
(ID);
if
(CaseUpdated !=
null
) CaseUpdated(
this
, e); }
Div
//MainUserControl
public
CaseProfileBL
CaseInvestigation {
get
;
set
; }
private
void
CaseProfileForm_Load(
object
sender,
EventArgs
e) { mainCaseUserControl.InitUserControl(); mainCaseUserControl.CaseUpdated +=
new
WindowsForm.UserControlTabs.MainCaseUserControl.
CaseUpdatedEventHander
( mainCaseUserControl_CaseUpdated);
}
void
mainCaseUserControl_CaseUpdated(
object
sender,
CaseUpdatedEventArgs
e)
{ SetTabPages(e.ID.Value); }
private
void
SetTabPages() {
if
(CaseInvestigation.ID ==
null
) {
return
; }
this
.tabControl1.Controls.Add(
this
.tabPageCaseProfile);
From the ParentForm, how do I pass the ID or value to UserControl2? And how do I retrieve the ID or value from my usercontrol to the form? I have to have an existing ID to save the data in UserControl2. Thank you
Reply
Answers (
0
)
Yahoo email account not open after i write this code in c#
Sending email