void bInsertColor_Click(object sender, EventArgs e) { if (colorPicker == null) { colorPicker = new ColorPicker("Insert color", 0); } if (colorPicker.ShowDialog() == DialogResult.OK) { string colorToInsert = MainForm.Parse(colorPicker.ColorIndex); int selectionStart = tText.SelectionStart; tText.Paste(colorToInsert); tText.Select(selectionStart, 2); tText.Focus(); } }