If the OS is Windows 8 or higher, you can make the child window a layered window. To do this, add an application manifest and enable Windows 8.
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
https://zcusa.951200.xyz/en-us/answers/questions/1433265/adding-transparent-form-in-panel
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
richTextBox1.HandleCreated += RichTextBox1_HandleCreated;
}
private void RichTextBox1_HandleCreated(object? sender, EventArgs e)
{
IntPtr hWnd = richTextBox1.Handle;
int exStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
SetWindowLong(hWnd, GWL_EXSTYLE, exStyle | WS_EX_LAYERED);
SetLayeredWindowAttributes(hWnd, ColorTranslator.ToWin32(richTextBox1.BackColor), 0, LWA_COLORKEY);
}
const int WS_EX_LAYERED = 0x00080000;
const int GWL_EXSTYLE = -20;
const int LWA_COLORKEY = 0x01;
const int LWA_ALPHA = 0x02;
[DllImport("user32.dll", SetLastError = true)]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool SetLayeredWindowAttributes(
IntPtr hWnd, int crKey, byte bAlpha, int dwFlags);
}