BINDING COMBO BOX

using combox box in user control and bind it with values
==========================================
//code behind of user control [e.g:-Name of u.c is ViewUserControl]
-In the constructor of this u.c bind the values of combo box
[ViewUserControl.cs]
public ViewUserControl(List<string> taskTypes)
{
 InitializeComponent();
 this.comboBoxName.DataSourse=tasktypes;
}

-To fill the combo box values from another class :-
e.g:-

We are adding values in combo box from ToolWindow.cs class then :-
[ToolWindow.cs]
public class ToolWindow
{
 private ViewUserControl viewControl;

 List<string> taskTypes=new list<string>();
 taskTypes.Add("task1");
 taskTypes.Add("task2");
 this.viewControl = new ViewUserControl(taskTypes);
}

No comments:

Post a Comment