Perhaps the window is hidden behind it.
[ToolboxItem(true)] // This attribute makes the control visible in the Toolbox
public class CustomButton : Button
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
// Constructor
public CustomButton() {
// Set default properties
this.BackColor = Color.Blue;
this.ForeColor = Color.White;
this.Text = "Custom Button";
Form FileLoadForm = new Form();
FileLoadForm.Controls.Add(new Button());
FileLoadForm.HandleCreated += (s, e) => {
SetForegroundWindow(((Control?)s)!.Handle);
};
FileLoadForm.ShowDialog();
}
}