I am currently encountering an issue while programming my new software.
I have a form which contains a datagridview
, some textboxes
, some numeric controls, some pictureboxes
and some of my own controls derived from UserControl
containing just some labels.
The issue is: when I load a form - the form is shown more or less blank and then the background of the controls and the content is loaded:
I dont know what else I could do to show the form only when everything is loaded... Do you have any ideas?
PS: All the loading of the data of the form is done inside the constructor
Edit: the event calling the form
private void LbSets_Click(object sender, EventArgs e)
{
frmTyreSet frmSets = new frmTyreSet();
frmSets.Show();
}
then the constructor
public frmTyreSet()
{
InitializeComponent();
fillDtTyres();
formatDGV();
addTyrePanels();
ExtensionMethods.dgvDoubleBuffered(dgvTyres, true);
}
and the functions
void fillDtTyres()
{
_dtTyres = new DataTable();
using (SqlConnection CONN = new SqlConnection(Properties.Settings.Default.dbConnStr))
{
CONN.Open();
string SQL = "SELECT * FROM [dbo].[TYRE] WHERE active = 'true' AND id > 1;";
SqlCommand CMD = new SqlCommand(SQL, CONN);
SqlDataAdapter ADAPTER = new SqlDataAdapter(CMD);
ADAPTER.Fill(_dtTyres);
CONN.Close();
}
}
void formatDGV()
{
dgvTyres.DataSource = _dtTyres;
//Setting visible columns
//Setting column header texts
//Setting column autosize modes
dgvTyres.DefaultCellStyle.ForeColor = Color.Black;
dgvTyres.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgvTyres.AutoResizeRows();
dgvTyres.AutoResizeColumns();
}
void addTyrePanels()
{
FL = new TyrePanel();
FL.Visible = true;
FL.Location = new Point(12, 253);
FL.T_position = "Front Left";
FL.DragEnter += TyrePanel_DragEnter;
FL.DragDrop += TyrePanel_DragDrop;
FL.DragOver += TyrePanel_DragOver;
FL.AllowDrop = true;
Controls.Add(FL);
FR = new TyrePanel();
FR.Visible = true;
FR.Location = new Point(584, 253);
FR.T_position = "Front Right";
FR.DragEnter += TyrePanel_DragEnter;
FR.DragDrop += TyrePanel_DragDrop;
FR.DragOver += TyrePanel_DragOver;
FR.AllowDrop = true;
Controls.Add(FR);
RL = new TyrePanel();
RL.Visible = true;
RL.Location = new Point(12, 468);
RL.T_position = "Rear Left";
RL.DragEnter += TyrePanel_DragEnter;
RL.DragDrop += TyrePanel_DragDrop;
RL.DragOver += TyrePanel_DragOver;
RL.AllowDrop = true;
Controls.Add(RL);
RR = new TyrePanel();
RR.Visible = true;
RR.Location = new Point(584, 468);
RR.T_position = "Rear Right";
RR.DragEnter += TyrePanel_DragEnter;
RR.DragDrop += TyrePanel_DragDrop;
RR.DragOver += TyrePanel_DragOver;
RR.AllowDrop = true;
Controls.Add(RR);
}