vb.net的窗体实际上是个坐标系,我想在这个窗体上动态显示点? vb.net的窗体实际上是个坐标系,我想在这个窗体上动态显示点. 我的方法是这样一来的,用两个文本框,一个用于输入X坐标,一个用于输入Y坐标,当(x,y)值输好以后,窗体中会显示这个点,用什么方法可以办到? 如果还要同时在点的上面显示点的坐标,应该怎么做? 给点建议吧和具体的做法。(学C#的朋友也许有这方面的经验,特把此帖发到这里) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Graphics _Graphics = Graphics.FromHwnd(this.Handle); Rectangle _Rect=new Rectangle(); _Rect.X=int.Parse(textBox1.Text); _Rect.Y = int.Parse(textBox2.Text); _Rect.Width=1; _Rect.Height=1; _Graphics.FillRectangle(Brushes.Blue,_Rect);C#的 参考如下代码 int x; int y; private void textBox1_TextChanged(object sender, EventArgs e) { int t=-1; if (int.TryParse((sender as TextBox).Text, out t)) { x = t; } this.Invalidate(); } private void textBox2_TextChanged(object sender, EventArgs e) { int t = -1; if (int.TryParse((sender as TextBox).Text, out t)) { y = t; } this.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle dotRect = Rectangle.FromLTRB(x - 1, y - 1, x + 1, y + 1); e.Graphics.DrawEllipse(SystemPens.WindowText, dotRect); e.Graphics.FillEllipse(SystemBrushes.ControlText, dotRect); e.Graphics.DrawString(string.Format("({0}, {1})", x, y), this.Font, SystemBrushes.ControlText, new Point(x, y)); } FFmpeg.NET.CSharp.2005怎么编译生成? debug自动生成文件夹 一小问题~,求救 用BeginPath()和EndPath()画复杂多边形遇到的问题 VS2005的工具箱里没有Mainmenu这个控件 placeholder和panel的区别? 请问用.net2003开发好的网站在本机没有错误,上传到FTP后,结果总是出现提示错误: C# 求助一个sql server 删除重复语句 Visual Studio 如何高亮当前行 C#2008+SQl2005,CS程序救急啊!!!! winform项目中我下载一个项目没有数据库,我怎么加?
_Rect.X=int.Parse(textBox1.Text);
_Rect.Y = int.Parse(textBox2.Text); _Rect.Width=1;
_Rect.Height=1;
_Graphics.FillRectangle(Brushes.Blue,_Rect);
C#的
int y;
private void textBox1_TextChanged(object sender, EventArgs e)
{
int t=-1;
if (int.TryParse((sender as TextBox).Text, out t))
{
x = t;
}
this.Invalidate();
} private void textBox2_TextChanged(object sender, EventArgs e)
{
int t = -1;
if (int.TryParse((sender as TextBox).Text, out t))
{
y = t;
}
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle dotRect = Rectangle.FromLTRB(x - 1, y - 1, x + 1, y + 1);
e.Graphics.DrawEllipse(SystemPens.WindowText, dotRect);
e.Graphics.FillEllipse(SystemBrushes.ControlText, dotRect);
e.Graphics.DrawString(string.Format("({0}, {1})", x, y), this.Font, SystemBrushes.ControlText, new Point(x, y));
}