标题:绘图移动问题
只看楼主
carl_bruce
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-11-24
结帖率:25%
已结贴  问题点数:10 回复次数:4 
绘图移动问题
我现在是想通过按键让直线每次左移5个像素,具体代码如下。运行 结果发现只有第一次按键有效,之后每次按键直线都不动,这是为什么?请大侠帮忙,多谢!
private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            int temp = 5;
            if (linestate == true)
            {
                label1.Text = e.KeyValue.ToString();
                if (e.KeyValue.ToString().Equals("74"))
                {
                    Graphics g = this.CreateGraphics();
                    Pen mypen = new Pen(Color.Blue, 5);
                    g.Clear(Color.FromArgb(240, 240, 240));
                    g.DrawLine(mypen, 100 - temp, 100, 300 - temp, 100);
                }
            }
        }
搜索更多相关主题的帖子: private 移动 按键 
2011-12-09 09:51
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
得分:5 
没有刷新

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2011-12-09 14:19
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
得分:0 
this.Refresh();

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2011-12-09 14:20
carl_bruce
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2011-11-24
得分:0 
   private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            
            int temp = 5;
            if (linestate == true)
            {
                label1.Text = e.KeyValue.ToString();
                if (e.KeyValue.ToString().Equals("74"))
                {
                    this.Refresh();
                    Graphics g = this.CreateGraphics();
                    Pen mypen = new Pen(Color.Blue, 5);
                    g.Clear(Color.FromArgb(240, 240, 240));
                    g.DrawLine(mypen, 100 - temp, 100, 300 - temp, 100);
                }
            }
            
        }

我试过了,没用
2011-12-09 16:57
冲冲走过
Rank: 2
等 级:论坛游民
帖 子:69
专家分:72
注 册:2011-10-2
得分:5 
temp=0;
  private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            
            int temp = 5;
            if (linestate == true)
            {
                label1.Text = e.KeyValue.ToString();
                if (e.KeyValue.ToString().Equals("74"))
                {
                    this.Refresh();
                    Graphics g = this.CreateGraphics();
                    Pen mypen = new Pen(Color.Blue, 5);
                    g.Clear(Color.FromArgb(240, 240, 240));
                    g.DrawLine(mypen, 100 - temp, 100, 300 - temp, 100);
                    temp+=5;

                }
            }
            
        }

2011-12-10 08:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-357356-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.099414 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved