好吧,我能得到這個做兩件事情的工作:
1)確保該字典將它傳遞給孩子的形式,而不是初始化一個空的字典子窗體之前進行初始化。
2)當子窗體關閉時,將字典指定回網格上的數據源。
這裏是父窗體的代碼顯示它在行動:
private void addColorCodeLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var assignedColorCodes =
(Dictionary<string, string>)this.subtypeColorCodesUltraGrid.DataSource;
//Initialize a null dictionary so that SubtypeColorCodeForm will reference the same dictionary.
if (assignedColorCodes == null)
assignedColorCodes = new Dictionary<string, string>();
SubtypeColorCodeForm.ShowForm(this, new ImageServerProxy(this.tbImagingUri.Text),
assignedColorCodes);
//Assign the updated dictionary back to the data source.
this.subtypeColorCodesUltraGrid.DataSource = assignedColorCodes;
}
你能證明你的一些代碼?打開子表單並傳遞字典的部分。 – Steve 2012-07-20 21:38:43
謝謝你的迴應,史蒂夫。我能夠得到它的工作,並在下面發佈解決方案。 – lintmouse 2012-07-23 14:48:51