因为只要是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;
}