datagridview加载头但行变得透明

时间:2018-06-27 00:33:05

标签: c# .net datagridview

因此将数据从sqlite数据库绑定到datagridview。 数据绑定恰好是绘图中的问题。首次加载/绑定数据时,它将加载标头,然后变得透明。如果在网格中滚动,它将显示数据,然后将其固定。另一个选择是第二次加载数据并对其进行修复。这是在启动程序和首次绑定数据时。第一件事之后的任何绑定都很好。 issue example 滚动example 2之后,示例2有望加载。以及即使在第二个数据库/表中加载,我也尝试在第一次加载后加载的所有数据。 现在iv尝试了什么

this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);
       this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);
        this.SetStyle(System.Windows.Forms.ControlStyles.ResizeRedraw, true);
        this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);
        this.SetStyle(System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer, true);

所以双缓冲区尝试了bin。 与闪烁控制相同

protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle = (cp.ExStyle | 33554432);
            return cp;
        }
    }

现在到绑定代码为止

sldt = new DataTable();
        try
        {
            SQLiteCommandBuilder builder = new SQLiteCommandBuilder(slda);
            using (conn)
            {
                conn.Open();
                sldt.Rows.Clear();
                if (Settings.TableExists("zShirts_Global_Tags", conn))
                {

                    var sql = ("SELECT * FROM zShirts_Global_Tags");
                    using (SQLiteCommand cmdDataGrid = new SQLiteCommand(sql, conn))
                    {

                        slda.SelectCommand = cmdDataGrid;
                        slda.Fill(sldt);
                        dgvSlideshow.DataSource = sldt;

                    }
                }
                conn.Close();
            }
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show(ex.ToString());
        }

  also tried dgvSlideshow.Refresh.(); dgvSlideshow.ResumeLayout();
至于显示的数据,其bs表用于其他地方,只是试图修复空白负载以使其干净。 任何帮助将不胜感激。 感谢您抽出宝贵的时间阅读和思考。

0 个答案:

没有答案