private void Type_SelectedIndexChanged(object sender, EventArgs e) { if (sender is ComboBox) { data.Type = (sender as ComboBox).SelectedItem.ToString(); } if (tmpShape != null) { int index = tabControlCanvas.SelectedTab.Controls[0].Controls.IndexOf(tmpShape); Shape shape = ShapeFactory.GetShapeInstance(ShapeFactory.GetTypeByNumber(cbType.SelectedIndex), tmpShape.Location.X, tmpShape.Location.Y, tmpShape.Height, tmpShape.Width, Convert.ToInt16(width.SelectedItem), colorPanel.BackColor); tabControlCanvas.SelectedTab.Controls[0].Controls.RemoveAt(index); tabControlCanvas.SelectedTab.Controls[0].Controls.Add(shape); tmpShape = null; } }