0
我在選項卡控件中有一個標籤,它用作隨機分配的ID號的「佔位符」。當用戶選擇加載醫療記錄表格時,應該給ID標籤分配一個隨機數字,將其中的文本從'在此處記錄ID'更改爲分配的數字。更改選項卡控件中標籤的值
我有另一個標籤,它不在選項卡控件中,但佈局方式相同(均在各自表單的構造函數中),並且它的功能完美。爲什麼會發生這個問題,並且可以對其進行排序?
居住在一個標籤控件的標籤代碼:
medicalRecordIDRand = new Random();
medicalRecordID = medicalRecordIDRand.Next(100000, 999999);
lblMedicalRecordID.Text = medicalRecordID.ToString();
MessageBox.Show("To add a new medical record, please choose 'Records', then 'New Record'. A unique ID number for this medical record has already been pre-assigned.", "For Your Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblMedicalRecordID.Text = medicalRecordID.ToString();
的標籤,該標籤可以正常工作的代碼:
patientIDRand = new Random();
patientIDNumber = patientIDRand.Next(1002, 9999);
MessageBox.Show("To add a new patient, please choose 'File', then 'New Patient'. A unique ID number for this patient has already been pre-assigned to this record.", "For Your Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
lblPatientIDProper.Text = patientIDNumber.ToString();
問題是什麼? – wdosanjos 2014-08-28 04:34:07
嗨。問題是我無法讓病歷ID標籤從其佔位符文本更改,當它被分配一個隨機數,並顯示該隨機數。 – Paul 2014-08-28 04:38:13
您是否確定佔位符文本在隨機數後沒有再次分配給'lblMedicalRecordID'? – wdosanjos 2014-08-28 04:42:35