日期:2014-05-18  浏览次数:20901 次

极菜的问题一个
出错信息如下:

错误 1 命名空间“System.Windows”中不存在类型或命名空间名称“Input”(是缺少程序集引用吗?) C:\Users\Administrator\Documents\Visual Studio 2008\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs 9 22 WindowsFormsApplication2
全部代码如下,出错部分已标红:

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;
using System.Windows.Input;
namespace WindowsFormsApplication2
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  textBox1.Text = "How are you?";
  this.Text = "我的第一个C#程序";
  this.SetBounds((Screen.GetBounds(this).Width / 2) - (this.Width / 2),
  (Screen.GetBounds(this).Height / 2) - (this.Height / 2),
  this.Width, this.Height, BoundsSpecified.Location);
  this.MaximizeBox = false;
  this.MinimizeBox = false;
  this.ControlBox = false;
  }

  private void button1_Click(object sender, EventArgs e)
  {
  MessageBox.Show(textBox1.Text);
  }

  private void textBox1_TextChanged(object sender, EventArgs e)
  {
   
  }

  private void button2_Click(object sender, EventArgs e)
  {
  Close();
  }

  private void Form1_Load(object sender, EventArgs e)
  {

  }

  private void Form1_Click(object sender, EventArgs e)
  {

  }

  private void Form1_DoubleClick(object sender, EventArgs e)
  {
  this.CenterToScreen();
  }

  private void Form1_MouseClick(object sender, MouseEventArgs e)
  {
  if (e.RightButton == MouseButtonState.Pressed)
  {
  MessageBox.Show("The Right Mouse Button is pressed");
  }

  }
  }
}


------解决方案--------------------
很明显System.Windows中没有Input,别瞎写
------解决方案--------------------
左右不分了晕 重写下


private void Form1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
MessageBox.Show("你点击了右键");
}
else if (e.Button == MouseButtons.Left)
{
MessageBox.Show("你点击了左键");
}
}