0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(WinForms) 超乱暴!Designer.csのイベントバインドコードを一掃する方法

Posted at

はじめに

本記事では、WinFormsの Designer.cs ファイルに自動生成されるコントロールのイベントバインドコードを一括で削除する超乱暴な方法を紹介します。
危険ですので、必ず自己責任でご利用ください。

手順

  1. Visual Studioで対象の .Designer.cs ファイルを開く
  2. 「検索と置換」ウィンドウを開く(Ctrl+H)
  3. 「正規表現を使用(.*アイコン)」を有効にする
  4. 検索文字列を「^.+=.\r?\n?」に、置換文字列は「」(空欄)にする
  5. スコープを「現在のドキュメント」にする

補足

+= を含む行が削除されます。
一般的に「+=」はイベントバインドに使われることが多いですが、他の用途にも使われる可能性があるので注意が必要です。誤って他の重要なコードを消さぬよう、実行前には十分な確認とバックアップを行ってください。

おわりに

この方法はとても手荒で強引なので、実行は慎重に。
必ず事前に Designer.cs のバックアップを取ってから実行してください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?