المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : c# adding events to programmaticlly added controls



C# Programming
07-22-2009, 03:00 PM
So the situation is the folowing

Inside a tabview control; i add programaticly a number of tabs (the number is not fixed); on each tab i add a listview. My question is how do i add an event item so that when i click any item from any list i fill a textbox with something from that item; my code looks like this


int i=0;
public void lv_SelectedIndexChanged(object sender, EventArgs e)
{while (n!=0)
{TabPage tp=new TabPage();
tabControl1.TabPages.Add(tp);

ListView lv = new ListView();
//setting som properties here and filling the list
tabControl1.TabPages[k].Controls.Add(lv);
}
}


I've written just a portion of the code.Help will be apreciated.Thank you in advance.
Alex.