You could use the Tag property of dropdownlist. First, create a simple DTO.
Up vote 1 down vote favorite share g+ share fb share tw.
LeCmb_Statut. SelectedIndexChanged += new EventHandler(LeCmb_Statut_SelectedIndexChanged); c# .net combobox dropdownlist selectedindexchanged link|improve this question edited May 20 '11 at 12:06forsvarir3,2644820 asked Feb 9 '11 at 10:16user6095111857 77% accept rate.
User609511: Describe more what you have and what do you want to reach. – abatishchev Feb 9 '11 at 10:18 Currently you are creating a new DropDownList for every record. Wouldn't it make more sense to add an Item to a pre-exisitng DropDownList?
– Henk Holterman Feb 9 '11 at 10:21.
You could use the Tag property of dropdownlist. First, create a simple DTO: public class LabelDTO { public string Label {get;set;} public string LabelVeh {get;set;} } then: while (reader.Read()) { ... DropDownList LeCmb_Statut = new DropDownList(); LabelDTO lbl= new LabelDTO(){Label=reader"LIBELLE".ToString(), LabelVeh=reader"LIBVEH".ToString()}; LeCmb_Statut. Tag=lbl; } then inside the LeCmb_Statut_SelectedIndexChanged: LeCmb_Statut_SelectedIndexChanged (object sender, System.
EventArgs e) { LabelDTO labelDTO= ((DropDownList)sender). Tag as LabelDTO ; if (labelDTO! =null) { ///here you can use the label and labelVeh properties.
} }.
You can use an anonymous method to capture them: string tempLabel = reader"LIBELLE".ToString(); string templabelVeh = reader"LIBVEH".ToString() LeCmb_Statut. SelectedIndexChanged += delegate { // do something fun with tempLabel and templabelVeh }; this could be inline for small blocks, or for longer code - just pass to a method: string tempLabel = reader"LIBELLE".ToString(); string templabelVeh = reader"LIBVEH".ToString() LeCmb_Statut. SelectedIndexChanged += delegate { DoSomethingFun(tempLabel,templabelVeh); }; or if you need the sender/args: string tempLabel = reader"LIBELLE".ToString(); string templabelVeh = reader"LIBVEH".ToString() LeCmb_Statut.
SelectedIndexChanged += delegate(object sender, EventArgs args) { DoSomethingFun(sender,args,tempLabel,templabelVeh); }; or in C# 3.0: string tempLabel = reader"LIBELLE".ToString(); string templabelVeh = reader"LIBVEH".ToString() LeCmb_Statut. SelectedIndexChanged += (sender, args) => DoSomethingFun(sender,args,tempLabel,templabelVeh).
Thanx you....it works – user609511 Feb 23 '11 at 12:26 @user609511: So that other users can benefit from the answer that you found worked for you, please consider accepting answers to those questions: See tinyurl.com/so-accept for more details. – forsvarir May 9 '11 at 9:48.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.