Hi....
I am developing c# windows application. In that , i have created one user control, it contains dropdownlist and textbox.In the form when i enter value 2 in a textbox (Ex:Two) i want two user controls should display i.e two dropdownlist and two textbox.
Loading
Sukesh MarlaPosted Aug 17, 2012, 2:38 AM
1.create eventhandler in usercontrol as
public delegate void TextChangeHandler(int x)
2.Create Event in UserControl as
public event TextChangeHandler TextChangeEvent;
3.In UserControl on textChange event
Raise above event with parsed textbox value as
textbox_change(....)
{
int Count=int.Parse(textbox.text);
if(TextChangeEvent!=null)
{
TextChangeEvent(Count);
}
}
4.In ur form add usercontrol and name it as uc1, inside panel panel1
5.Add handler as
uc1.TextChangeEvent+=new TextChangeHandler(myhandler);
.
.
.
public void myHandler(int s)
{
for(i=0;i
{MyUserControl cc=new MyUserControl();
c.width=..;
c.height=...;
c.left=..;
c.top=..;
c.TextChangeEvent+=new TextChangeHandler(myhandler);
panel1.controls.add(c);
}
}
Thats it.
Hope it helped.
Check this is correct answer