Click here to Skip to main content
16,015,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Created Winusercontrol consist of 1 form and 1 panel. Draw some text on paint event of panel of user control. Add reference of usercontrol in my application.

usercontrol code:
C#
bool flag=false;
public void Somthing()
{
  ///some code...
  ///
  flag=true;
}

protected void panel_paint(PainteventArgs e)
{
 if(flag==true)
   //draw some text
}

Form Application code:
C#
private void frmMain_Load(object sender, EventArgs e)   
{
   usercontrol obj=new usercontrol();
   obj.Somthing();
}
when i created object of library and call Somthing(). flag value will be false. so no text will be drawn i dont know why flag value will be reset
Posted
Updated 26-May-13 23:47pm
v2
Comments
lukeer 27-May-13 6:09am    
Are you sure there's only one flag variable? Not one in member scope and another in local scope of Something()?
[no name] 27-May-13 6:42am    
flag will be set as global variable
only once
Sunasara Imdadhusen 27-May-13 7:48am    
When Somthing() function will called??
[no name] 27-May-13 9:45am    
after creation of object usercontrol. i explicitly explain in question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900