MemoryStream问题(PictureBox) [英] Problem with MemoryStream (PictureBox)

查看:267
本文介绍了MemoryStream问题(PictureBox)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我有一个DataGridView.每次单击网格时,网格的项目都会传递到TextBoxes和PictureBox(因为网格中有图像项目).我感到困惑的是,我必须延迟单击网格中的项目约10秒钟.如果我不拖延地单击它,则会导致错误.例如,如果我每隔15秒单击一次,它将正常运行.网格填充访问数据库中的数据.怎么解决呢?提前谢谢您.
这是代码

Hi all. I have a DataGridView. Each time I click the grid the items of the grid will be delivered to TextBoxes and a PictureBox (since the grid has an image item). What I''m confusing of is I have to delay clicking the items in the grid for about 10 seconds. If I click it without delaying it causes error. And if I click it every 15 seconds, for example, it runs normally. The grid populates data from an access database. How to solve it? Thank you in advance.
Here is the code

Private Sub DataGridView1_CellClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick

        Dim i As Integer = DataGridView1.CurrentRow.Index

        Me.lblGridName.Text = DataGridView1.Item(0,i).Value
        Me.lblGridAge.Text = DataGridView1.Item(1,i).Value

        Dim gb() As Byte = CType(DataGridView1.Item(2,i).Value, Byte())
        Dim stm As New MemoryStream(gb)
        Me.PictureBox1.Image = Image.FromStream(stm)

End Sub

推荐答案

我已经考虑过一种方法,可以将点击延迟10秒钟,但这并不是解决问题的好方法.

您可以做的就是添加一个计时器,一旦用户单击dataview网格,就启动计时器,并禁用该网格.计时器结束后(将其设置为10秒-1000),再次启用网格.

我不太了解Dataview网格,因此这可能行不通,并且使用计时器解决此问题并不是世界上最好的解决方案,但是如果确实可行,则可以暂时使用它,直到找到更好的解决方案为止建议.

希望我能有所帮助.
祝你好运:-)
I have thought of a way you may be able to delay clicking for 10 seconds but it isn''t a very good way of going about it.

What you could do is add a timer, start the timer once the user clicks on a dataview grid, and disable the grid. Once the timer has finished (set it to 10 seconds - 1000) enable the grid again.

I don''t really know much about Dataview grids so this may not work, and using timers to solve this issue is not the best solution in the world but if this does work it can be used for the time being until a better solution is suggested.

Hope I have been of some help.
Good Luck :-)


这篇关于MemoryStream问题(PictureBox)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆