Есть код пользовательского TextBox (ReadOnlyTextBox), который размещается неоднократно на форме с помощью панели элементов:
using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class ReadOnlyTextBox : TextBox
{
[DllImport("user32.dll")]
static extern bool HideCaret(IntPtr hWnd);
public ReadOnlyTextBox()
{
this.ReadOnly = true;
this.BackColor = Color.White;
this.GotFocus += TextBoxGotFocus;
this.Cursor = Cursors.Arrow;
}
private void TextBoxGotFocus(object sender, EventArgs args)
{
HideCaret(this.Handle);
}
}
Подскажите пожалуйста, как корректно освободить память от "this.GotFocus += TextBoxGotFocus;", надо прописывать "this.GotFocus -= TextBoxGotFocus;" в коде формы?