C# Winforms Constructor being called when settting visible to true

Overall problem is a screen performance issue. Here is what I “think” I have found out. It appears the constructor gets ran again when setting visible to true? I am not 100% sure about that as I am new to performance profiling. When I am looking at a form that I pre-load that is not visible then when the form is supposed to be shown I set the visible property to true I see entries calling the Constructor again which I am really confused at why that would be happening. Based on what I have read is that OnLoad should be called which I don’t have anything in there but I do have a custom control that I made to be used for every button on the screen as this is a touch screen type situation. I waited a while before I tried to call on the screen I am trying to debug and then captured the performance metric in that time frame. What you would see is the custom buttons being loaded from the bottom right of the screen up to the top left and takes less than 1.5 seconds but still it’s slow enough it makes me question what Is actually happening.

That’s why I started doing a performance profile using visual studio 2022. The custom control is literally the following.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Layout;
namespace Wagon_Wheel_Net_Project
{
internal class Custom_all_btn : Button
{
private bool ShouldDraw = false;
private LinearGradientBrush myBrush = null;
private int pluNO = 0;
private decimal price;
public All_Items.Item item { get; set; }
public bool selected { get; set; }
private bool dialogObject { get; set; }
PictureBox selectedpic = new PictureBox();
PictureBox checkedbox = new PictureBox();
public List<All_Items.Item> Items { get; set; }
public All_Items.sandwich sandwich { get; set; }
public All_Items.specialty_sandwich specialty { get; set; }
public All_Items.specialty_wrap specialtywrap { get; set; }
public All_Items.soup soup { get; set; }
public All_Items.Hot_Dog Hot_Dog { get; set; }
public Custom_all_btn()
{
}
public Custom_all_btn(string txt)
{
TextAlign = ContentAlignment.MiddleCenter;
Text = txt;
selected = false;
Items = new List<All_Items.Item>();
//this.Font = new Font("Segoe UI",14,FontStyle.Bold);
}
public Custom_all_btn(string txt, Image img, int plu, decimal price)
{
this.DoubleBuffered = true;
TextAlign = ContentAlignment.BottomCenter;
ImageAlign = ContentAlignment.TopCenter;
pluNO = plu;
Image = img;
Text = txt;
selected = false;
Items = new List<All_Items.Item>();
}
}
}
</code>
<code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Windows.Forms.Layout; namespace Wagon_Wheel_Net_Project { internal class Custom_all_btn : Button { private bool ShouldDraw = false; private LinearGradientBrush myBrush = null; private int pluNO = 0; private decimal price; public All_Items.Item item { get; set; } public bool selected { get; set; } private bool dialogObject { get; set; } PictureBox selectedpic = new PictureBox(); PictureBox checkedbox = new PictureBox(); public List<All_Items.Item> Items { get; set; } public All_Items.sandwich sandwich { get; set; } public All_Items.specialty_sandwich specialty { get; set; } public All_Items.specialty_wrap specialtywrap { get; set; } public All_Items.soup soup { get; set; } public All_Items.Hot_Dog Hot_Dog { get; set; } public Custom_all_btn() { } public Custom_all_btn(string txt) { TextAlign = ContentAlignment.MiddleCenter; Text = txt; selected = false; Items = new List<All_Items.Item>(); //this.Font = new Font("Segoe UI",14,FontStyle.Bold); } public Custom_all_btn(string txt, Image img, int plu, decimal price) { this.DoubleBuffered = true; TextAlign = ContentAlignment.BottomCenter; ImageAlign = ContentAlignment.TopCenter; pluNO = plu; Image = img; Text = txt; selected = false; Items = new List<All_Items.Item>(); } } } </code>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Layout;

namespace Wagon_Wheel_Net_Project
{
    internal class Custom_all_btn : Button
    {
        private bool ShouldDraw = false;
        private LinearGradientBrush myBrush = null;
        private int pluNO = 0;
        private decimal price;
        public All_Items.Item item { get; set; }
        public bool selected { get; set; }
        private bool dialogObject { get; set; }
        PictureBox selectedpic = new PictureBox();
        PictureBox checkedbox = new PictureBox();
        public List<All_Items.Item> Items { get; set; }
        public All_Items.sandwich sandwich { get; set; }
        public All_Items.specialty_sandwich specialty { get; set; }
        public All_Items.specialty_wrap specialtywrap { get; set; }
        public All_Items.soup soup { get; set; }
        public All_Items.Hot_Dog Hot_Dog { get; set; }

        public Custom_all_btn()
        {
        }

        public Custom_all_btn(string txt)
        {
            TextAlign = ContentAlignment.MiddleCenter;
            Text = txt;
            selected = false;
            Items = new List<All_Items.Item>();
            //this.Font = new Font("Segoe UI",14,FontStyle.Bold);
        }

        public Custom_all_btn(string txt, Image img, int plu, decimal price)
        {
            this.DoubleBuffered = true;
            TextAlign = ContentAlignment.BottomCenter;
            ImageAlign = ContentAlignment.TopCenter;
            pluNO = plu;
            Image = img;
            Text = txt;
            selected = false;
            Items = new List<All_Items.Item>();


        }

        
    }
}

Its just text at the top and a picture box at the bottom. I format the text using a font. There is approximately 12-17 of the buttons on each Winform. So I am unsure how to diagnose any further. Any guidance would be greatly appreciated.

Tried performance profiling and did not expect to see the constructor being called on a already pre-loaded form.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật