在图片框中显示字符串 [英] Displaying a string in a picture box

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

问题描述

我正在尝试开发游戏.我正在使用图片框,并希望在图片框上显示数字.我正在使用以下代码,但是字符串未显示在图片框上.

 PictureBox pb =  PictureBox();
pb.Parent = panel1;
图形g = pb.CreateGraphics();
g.DrawString(" 字体("  10  ),Brushes.Black,点( 100  700 ));
pb.Size =大小;
pb.Visible =  true ;
pb.Location =  Point(i +(i *  70 ),j +(j *  70 ));
pb.Visible =  true ;
pb.AllowDrop = ; 



解决方案

引用该线程,可能有帮助
http://stackoverflow.com/questions/849359/how-to-draw-text-图片框 [ ^ ]


尝试在图片"框的Paint事件中编写此代码.
此处 [PictureBox pb = new PictureBox(); pb.Parent = panel1; Graphics g = pb.CreateGraphics(); g.DrawString("1", new Font("Arial", 10), Brushes.Black, new Point(100, 700)); pb.Size = size; pb.Visible = true; pb.Location = new Point(i + (i * 70), j + (j * 70)); pb.Visible = true; pb.AllowDrop = true;



Please let me know where am I going wrong?

解决方案

Refer this thread, might help
http://stackoverflow.com/questions/849359/how-to-draw-text-on-picturebox[^]


Try writing this code in the Paint event of the Picture box.
Here[^] is a very simple example.


这篇关于在图片框中显示字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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