如何在消息框中显示图像数据 [英] How to display image data in message box

查看:75
本文介绍了如何在消息框中显示图像数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SqlConnection cnn = new SqlConnection(@"Data Source=DANNY-PC\SQLEXPRESS;Initial Catalog=coba;Integrated Security=True;Pooling=False");
                byte[] imgData = File.ReadAllBytes(pictureBox1.ImageLocation);
                MessageBox.Show(Convert.ToString(imgData)); // How to display image data in message box?
                int varID = Convert.ToInt16(textBox1.Text);
                string varNama = textBox2.Text;
                SqlCommand cmd = new SqlCommand("INSERT INTO Table2 (ID,Nama,Foto) VALUES (@ID,@Nama,@Foto)", cnn);
                cmd.Parameters.Add("@ID", varID);
                cmd.Parameters.Add("@Nama", varNama);
                cmd.Parameters.Add("@Foto", imgData);
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();





删除了SHOUTING - OriginalGriff [/ edit]



[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

首先,这不是一个明智的问题。

这个论坛中有工具允许格式化,你不应该只是将代码转储到问题中框。你应该格式化它,然后描述你想要实现的目标以及你的问题是什么。



其次,



我相信您需要创建自己的表单作为消息框才能显示您的图像。根据我的经验,.Net框架中的MessageBox需要传递字符串,并且不希望显示任何图像。



如果您创建表单,则可以使用选项将其配置为有点像消息框,但这取决于你。
Firstly, This is not a sensible question.
There are tools present in this forum to allow for formatting and you shouldn't just dump code into the question box. You should format it and then describe what you are trying to achieve and what your issue is clearly.

Secondly,

I believe you would need to create your own form to act as a "message box" in order to display your image. The MessageBox in the .Net framework in my experience expects strings to be passed and does not expect to have to display any images.

If you create a form, you can use the options to configure it to be a bit like a message box but that will up to you.


这篇关于如何在消息框中显示图像数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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