通过控件 C# 绘制和清除字符串
经过谷歌搜索后,我得到了一些例子,但没有一个给我我需要的东西。
我需要在 ButtonClick
上将一个字符串 (WriteString()
) 写入 WinForm 中的控件中,并且我需要更新该绘图,因为我正在尝试写入日期进入控件,系统日期。
因此,每次用户单击该按钮时,DateTime.Now.ToString();
都应该被绘制到控件中。
最好的
After some search at Google I had some examples but none of them gave me what I need.
I need to write a String (WriteString()
) into a Control in WinForm on a ButtonClick
and I need to update that Draw, because i'm trying to write the Date into the Control, the System Date.
So each time the user clicks on that Button the DateTime.Now.ToString();
should be drawn into the Control.
Bests
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在标签上绘制字符串
url 肯定会对你有帮助,
那里写的代码是
draw a string on label
this url will surely help you
the code written there is
您应该考虑使用 winforms Label 和计时器。
You should consider using a winforms Label and a Timer for that.
或者您可以修改控件的 OnPaint 方法来覆盖控件的绘制方式。 Graphics 对象中有一个方法可以让你写一个字符串 g.DrawString
Or you could modify the OnPaint method of the control to override how the control is painted. There is a method in the Graphics object that lets you write a string g.DrawString