采用该守则(名单复制为名单监控):
private void ShowApplicationPropertiesForm() {
String FullPath = String.Empty;
String Title = String.Empty;
String Description = String.Empty;
Boolean Legacy = false;
Boolean Production = false;
Boolean Beta = false;
MyCustomListViewItemDescendant lvi = (MyCustomListViewItemDescendant)listApplications.SelectedItems[0];
FullPath = lvi.ExePath;
Title = lvi.Text;
Description = lvi.ToolTipText;
ApplicationProperties ap = new ApplicationProperties(
FullPath,
Title,
Description,
Legacy,
Production,
Beta);
ap.Show();
}
//overloaded form constructor
public ApplicationProperties(String AFullPath, String ATitle, String ADescription, Boolean ALegacy, Boolean AProduction, Boolean ABeta) {
this.Text = String.Format("{0} Properties", ATitle);
textBoxFullPath.Text = AFullPath;
textBoxTitle.Text = ATitle;
textBoxDescription.Text = ADescription;
checkBoxLegacy.Checked = ALegacy;
checkBoxProduction.Checked = AProduction;
checkBoxBeta.Checked = ABeta;
}
...I m getting, "System.NullReferenceException was unhandled Message=Object reference not set to an instance of an object."
炸弹穿透:
textBoxFullPath.Text = AFullPath;
文本BoxFull 途径是一种形式的文本箱; 整体健康具有某种有效价值:“Q:什么是青年,什么是青年。
Updated:
部分解决。
这是旧的“自然转让”问题。 通过将任务从建筑商移至Load()活动,它不再有炸弹(下文编码)。
HOWEVER, 现在没有任何东西在运行时展示这种形式?
public partial class ApplicationProperties : Form {
String _fullPath = String.Empty;
String _title = String.Empty;
String _description = String.Empty;
Boolean legacy = false;
Boolean production = false;
Boolean beta = false;
public ApplicationProperties() {
InitializeComponent();
}
public ApplicationProperties(String AFullPath, String ATitle, String ADescription, Boolean ALegacy, Boolean AProduction, Boolean ABeta) {
_fullPath = AFullPath;
_title = ATitle;
_description = ADescription;
legacy = ALegacy;
production = AProduction;
beta = ABeta;
this.CenterToScreen();
}
private void ApplicationProperties_Load(object sender, EventArgs e) {
//this.Text = String.Format("{0} Properties", _title);
Text = String.Format("{0} Properties", _title);
textBoxFullPath.Text = _fullPath;
textBoxTitle.Text = _title;
textBoxDescription.Text = _description;
checkBoxLegacy.Checked = legacy;
checkBoxProduction.Checked = production;
checkBoxBeta.Checked = beta;
}
更新:
向超负荷的建筑商添加“InitializeComponent();”是骗局的。 页: 1