因爲只要是List等的控件,都是有很多的item組成的,所以在判斷List等的控件的長度的時候,也就是判斷的是items的個數,根據個數的不同實現不同的操作。
int dizhiCount= this.danxuandizhi.Items.Count;
if (dizhiCount==0) //表示還沒有收貨地址
{
this.addDizhi.Visible = true;
//this.danxuandizhi.Text="無收貨地址";
}
else
{
this.addDizhi.Visible = false;
this.danxuandizhi.Visible = true;
}