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 WindowsFormsApplication1
{
    public partial class frmViewer : Form
    {
        public frmViewer()
        {
            InitializeComponent();
        }        private void fimviewer_Load(object sender, EventArgs e)
        {        }        private void btnselectpicture_Click(object sender, EventArgs e)
        {
            //show the open file dialog box.
            if(ofdSelectPicture.ShowDialog()==DialogResult.OK)
            {
                //Load the picture into the picture box.
                picShowPicture.Image=Image.FromFile(ofdSelectPicture.FileName);
                //show the name of the file in the form's caption.
                this.Text=string.Concat("Picture View("+ofdSelectPicture.FileName+")"); 
            }
        }
    }        private void btnquit_Click(object sender, EventArgs e)
        {
            //close window and exit the application
            this.Close();
        }
}

解决方案 »

  1.   

    提示错误 1 应输入 class、delegate、enum、interface 或 struct C:\Users\Administrator\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\frmViewer.cs 37 17 WindowsFormsApplication1
      

  2.   

     public partial Class frmViewer : Form
      

  3.   

    private void btnquit_Click(object sender, EventArgs e)
    {
        //close window and exit the application
        this.Close();
    }这个方法你粘贴错位置了。需要放在类里,你贴到类外面了。
      

  4.   

    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 WindowsFormsApplication1
    {
        public partial class frmViewer : Form
        {
            public frmViewer()
            {
                InitializeComponent();
            }        private void fimviewer_Load(object sender, EventArgs e)
            {        }        private void btnselectpicture_Click(object sender, EventArgs e)
            {
                //show the open file dialog box.
                if (ofdSelectPicture.ShowDialog() == DialogResult.OK)
                {
                    //Load the picture into the picture box.
                    picShowPicture.Image = Image.FromFile(ofdSelectPicture.FileName);
                    //show the name of the file in the form's caption.
                    this.Text = string.Concat("Picture View(" + ofdSelectPicture.FileName + ")");
                }
            }
            private void btnquit_Click(object sender, EventArgs e)
            {
                //close window and exit the application
                this.Close();
            }
        }
    }
    这样就对了。
      

  5.   

    哦!!
    你的那个大括号括错了!!!
      private void btnquit_Click(object sender, EventArgs e)
      {
      //close window and exit the application
      this.Close();
      }
    应该放里面的!!
      

  6.   

    private void btnselectpicture_Click(object sender, EventArgs e)
    这块多了个},删一个掉
      

  7.   

    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 WindowsFormsApplication1
    {
      public partial class frmViewer : Form
      {
      public frmViewer()
      {
      InitializeComponent();
      }  private void fimviewer_Load(object sender, EventArgs e)
      {  }  private void btnselectpicture_Click(object sender, EventArgs e)
      {
      //show the open file dialog box.
      if(ofdSelectPicture.ShowDialog()==DialogResult.OK)
      {
      //Load the picture into the picture box.
      picShowPicture.Image=Image.FromFile(ofdSelectPicture.FileName);
      //show the name of the file in the form's caption.
      this.Text=string.Concat("Picture View("+ofdSelectPicture.FileName+")");  
      }
      }
      //}多了一个大括号   private void btnquit_Click(object sender, EventArgs e)
       {
      //close window and exit the application
      this.Close();
       }
     }
    }//少了一个大括号