我在表单中调用usercontrol的方法,但usercontrol中的Combobox不包含调用方法中的任何项。当我在不使用调用的情况下运行相同的方法(即直接在用户控件中放置按钮并运行相同的方法)时,组合框具有项目。代码如下。
Form1中的代码:
Type type = ActiveModelControl.GetType();
var control = Activator.CreateInstance(type);
MethodInfo method = type.GetMethod("RunSimulation");
object[] param = new object[] { modelinfo };
var results = method.Invoke(control, param);
userontrol中的代码:
public List<double> RunSimulation(IModel model)
{
[other code]
List<string> tempSecurityList =
GetSecurityList(SecurityListComboBox.SelectedItem.ToString());
[other code]
}