private void RenameControl() { try { var form = _view.Target.QualifiedName.QualifiedModuleName.Component.CodeModule; var control = ((dynamic)form.Parent.Designer).Controls(_view.Target.IdentifierName); foreach (var handler in _declarations.FindEventHandlers(_view.Target)) { var newMemberName = handler.IdentifierName.Replace(control.Name + '_', _view.NewName + '_'); var module = handler.Project.VBComponents.Item(handler.ComponentName).CodeModule; var content = module.get_Lines(handler.Selection.StartLine, 1); var newContent = GetReplacementLine(content, handler.IdentifierName, newMemberName); module.ReplaceLine(handler.Selection.StartLine, newContent); } control.Name = _view.NewName; } catch (RuntimeBinderException) { } catch (COMException) { } }