我想要做的是保存列表框的所有填充参考键列表。将有未知数量的线路(用户/“患者”)。保存列表后,我希望能够使用列表框索引来查找相应的键,并使用它来转到下一部分。正在初始化数据引用的字符串数组
public partial class PatientList : Window
{
HumanResources ListAllPatients;
List<PatientInformation> AllPatients;
string[] Usernames;
public PatientList()
{
InitializeComponent();
int i = 0;
string[] Usernames = new string[i];
ListAllPatients = new HumanResources();
AllPatients = ListAllPatients.PopPatientList();
foreach (PatientInformation PatientChoice in AllPatients)
{
Usernames[i] = PatientChoice.Username;
lboxPatients.Items.Add(string.Format("{0} {1}; {2}", PatientChoice.FirstName, PatientChoice.LastName, PatientChoice.Gender));
i += 1;
}
}
这里是你移动到下一个部分的按钮的代码
public void btnSelectPatient_Click(object sender, RoutedEventArgs e)
{
PatientInfo PatientInfoWindow = new PatientInfo();
PatientInfoWindow.Show();
//i = lboxPatients.SelectedIndex;
//UserFactory.CurrentUser = Usernames2[i];
this.Close();
}
我的问题是这样的:我相信我已经初始化字符串数组来做到这一点,但保持VS告诉我它没有被分配到,并且一直保持为空。
我的问题:为了完成从PatientList()向btnSelectPatient发送密钥,我如何以及在哪里正确初始化字符串数组(或更好的方法)?
你在哪里初始化它? –
我相信我已经初始化它在最上面,在List AllPatients –
Erick