private void label16_MouseEnter(object sender, EventArgs e)
{
panelSummary.Show();
StockInfo temp = Game.getStockByLabelName(label16.Text);
// StockComp.Text = "Stock Company = " + temp.getStockName();// I got errors in this line
lbDispStockPrice.Text = "Stock price = " + temp.getPrice();
lbDispStock.Text = "Stock category = " + temp.getCategory();
owner.Text = "Property Of " + temp.getBuyer();
}
问问题
41 次
2 回答
1
要在您指示的行上“停止异常”,请检查null
由GetStockByLabelName
StockInfo temp = Game.getStockByLabelName(label16.Text);
if(temp != null)
{
StockComp.Text = "Stock Company = " + temp.getStockName();//if temp is null then EX
//...
}
else
//do whatever is appropriate for the situation where StockInfo is null
StockComp.Text 可能导致错误。我认为这是TextBox
在设计师中创建的不太可能。
于 2013-10-30T16:10:39.817 回答
0
确保这些引用中的每一个都不是null
:
panelSummary
temp
lbDispStockPrice
lbDispStock
owner
我的猜测是temp
因为其他似乎是视觉组件,这意味着在Game.getStockByLabelName
将null
值传递给label16.Text
.
这是调试器派上用场的地方......
于 2013-10-30T16:06:27.223 回答