返回首页

您好,
我有一个SQL表,它包含在图像格式Flightimages

&# 160; FlightImage FlightName
binarydata日落
莲花binarydata
  ; 冬季binarydata
蓝山binarydata

我绑定到DataGridView的上述表。 DataGridView中包含一个DataGridView的图像coloumn。我的要求是插入到DataGridView的图像单元的两个标贴。
加载到两个标贴图片名称

即细胞lool喜欢下面的

日落
图片
&# 160; 日落

对于插入细胞内的两种标贴,我用绘画。

我的编码是


  private void Form1_Load(object sender, EventArgs e)

        {

 

            SqlConnection con = new SqlConnection("server=sts5;uid=sa;password=sst;database=master");

            con.Open();

            SqlDataAdapter da = new SqlDataAdapter("select * from Images", con);

            ds = new DataSet();

            da.Fill(ds, "upload");

            dataGridView1.DataSource = ds.Tables[0];

            con.Close();  

}

 

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)

{            if (e.RowIndex > -1)

            {  if (e.ColumnIndex != -1)

                {

                    e.Paint(e.CellBounds, DataGridViewPaintParts.All);

                 

                    foreach (DataGridViewRow drrow in dataGridView1.Rows)

                    {

                        if (e.ColumnIndex == 0 && e.RowIndex > -1 && e.RowIndex != this.dataGridView1.NewRowIndex)

                        {

                            string[] FlightCode= dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();

 

                            Rectangle img1 = e.CellBounds;

                            Rectangle textRect = e.CellBounds;

                            Rectangle textRect1 = e.CellBounds;

                            textRect.Width -= e.CellBounds.Width / 2;

                            textRect.Height = -2;

                            textRect1.Width -= e.CellBounds.Width / 2;

                            textRect1.Height = 36;

                            Rectangle textbox = e.CellBounds;

                            textbox.Width = e.CellBounds.Width / 2;

                            textbox.Height = 10;

                            Rectangle lblFlight = e.CellBounds;

                            lblFlight.Y += textRect.Height;

                            lblFlight.Width = e.CellBounds.Width;

                            lblFlight.Height = 0;

                            Rectangle lblFlightCode = e.CellBounds;

                            lblFlightCode.Y += textRect1.Height;

                            lblFlightCode.Width = e.CellBounds.Width;

                            lblFlightCode.Height = 20;

                            e.Paint(lblFlight, DataGridViewPaintParts.All);

                            e.Paint(lblFlightCode, DataGridViewPaintParts.All);

                            e.Handled = true;

                            StringFormat formater = new StringFormat();

 

                            formater.Alignment = StringAlignment.Center;

                            Font fnt = new Font("Verdana", 7);

                            using (SolidBrush br = new SolidBrush(Color.Black))

                            {

                                e.Graphics.DrawString(FlightCode, fnt, br, lblFlightCode, formater);

                                e.Graphics.DrawString(FlightCode, fnt, br, lblFlight, formater);    }

 

                          }

                    }

 

                    e.Handled = true;

                }

            }

        }

          

 


我写的上述规定细胞的画。我的疑问是,我有没有我的Sql画像表中的行。后运行我的项目,为什么,因为发射细胞画事件每SECON的的DataGridView的形象细胞得到震动和从上到下的IAM滚动DataGridView的图像然后也细胞振动。
坏看这成为我的客户。
避免这种情况我能做些什么,请帮助我。

感谢有关

回答

评论会员: 时间:2
D