日期:2014-05-17 浏览次数:20541 次
MenuItem i = new MenuItem();
Menu1.Items.Add(i);
Menu1.Items.Add(i);
public void Add(MenuItem child)
{
this.AddAt(this._list.Count, child);
}
public void AddAt(int index, MenuItem child)
{
if (child == null)
{
throw new ArgumentNullException("child");
}
if ((child.Owner != null) && (child.Parent == null))
{
child.Owner.Items.Remove(child);
}
if (child.Parent != null)
{
child.Parent.ChildItems.Remove(child);
}
if (this._owner != null)
{
child.SetParent(this._owner);
child.SetOwner(this._owner.Owner);
}
this._list.Insert(index, child);
this._version++;
if (this._isTrackingViewState)
{
((IStateManager) child).TrackViewState();
child.SetDirty();
}
this.Log.Add(new LogItem(LogItemType.Insert, index, this._isTrackingViewState));
}