完全涂漆前显示的表格

时间:2018-02-05 14:11:48

标签: c# forms

我正在编程新软件时遇到问题。

我有一个表单,其中包含datagridview,一些textboxes,一些数字控件,一些pictureboxes以及一些我自己的控件派生自UserControl只包含一些标签

问题是:当我加载表单时 - 表单显示或多或少空白,然后加载控件的背景和内容:

1

我不知道还有什么我可以做的只是当一切都被加载时才显示表格...你有什么想法吗?

PS:表单数据的所有加载都在constructor

内完成

编辑: 调用表单的事件

    private void LbSets_Click(object sender, EventArgs e)
    {
        frmTyreSet frmSets = new frmTyreSet();
        frmSets.Show();
    }

然后是构造函数

    public frmTyreSet()
    {
        InitializeComponent();

        fillDtTyres();
        formatDGV();
        addTyrePanels();

        ExtensionMethods.dgvDoubleBuffered(dgvTyres, true);
    }

和功能

    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);
    }

0 个答案:

没有答案