日期:2014-05-17  浏览次数:20660 次

贴出自己刚刚开始学习C#的前几天写的代码,不知不觉过了好长时间了。下班结贴,散分~~
下班结贴,散分

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ActiveForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        int x = 5;
        int y = 5;

        private void Form1_Load(object sender, EventArgs e)
        {
            Init();
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Left += x;
            this.Top += y;
            if (this.Left < 0 || this.Left > Screen.PrimaryScreen.WorkingArea.Width - this.Width)
            {
                x = -x;
            }
            if (this.Top < 0 || this.Top > Screen.PrimaryScreen.WorkingArea.Height - this.Height)
            {
                y = -y;
            }
        }

        private void Init()
        {
            timer1.Interval = 1;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        }
    }
}

------解决方案--------------------
lz学C#多长时间了?
------解决方案--------------------

------解决方案--------------------
哥也在学c# 说说自己的感受吧, 我主要是写应用软件不是往web方向的,现在写个简单的单窗体的程序还是没问题的。 最难的还是多窗体的MID应用程序,一开始还是从事件 委托 开始了解起,呵呵操作access数据库 现在也知道了些。。希望楼主加油!
------解决方案--------------------