System.ComponentModel.Container.Remove C# (CSharp) Method

Remove() private method

private Remove ( IComponent component, bool preserveSite ) : void
component IComponent
preserveSite bool
return void
        private void Remove(IComponent component, bool preserveSite)
        {
            lock (_syncObj)
            {
                if (component == null)
                    return;
                ISite site = component.Site;
                if (site == null || site.Container != this)
                    return;
                if (!preserveSite)
                    component.Site = null;
                for (int i = 0; i < _siteCount; i++)
                {
                    if (_sites[i] == site)
                    {
                        _siteCount--;
                        Array.Copy(_sites, i + 1, _sites, i, _siteCount - i);
                        _sites[_siteCount] = null;
                        _components = null;
                        break;
                    }
                }
            }
        }

Same methods

Container::Remove ( IComponent component ) : void

Usage Example

		public void SetDraggable(Control control, bool value)
		{
			if (value)
			{
				if (!GetDraggable(control))
				{
					this._container.Add(control);
					control.MouseDown+=new MouseEventHandler(control_MouseDown);
				}
			} 
			else
				if (GetDraggable(control))
			{
				_container.Remove(control);
			}
		
		}
All Usage Examples Of System.ComponentModel.Container::Remove