| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1228 人关注过本帖
标题:求救!!
只看楼主 加入收藏
chenggan
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2005-4-14
收藏
 问题点数:0 回复次数:14 
求救!!

在运行了这样一个程序后出现以下错误: F:\新建文件夹\WindowsApplication3\Form1.cs(108): 找不到类型或命名空间名称“PictureBox1”(是否缺少 using 指令或程序集引用?) 请问应该怎么样修改啊? using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO;

namespace WindowsApplication3 { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.Windows.Forms.PictureBox pictureBox1; private System.ComponentModel.Container components=null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TOD 在 InitializeComponent 调用后添加任何构造函数代码 // }

/// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }

#region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(0, 8); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(288, 256); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.pictureBox1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false);

} #endregion

private void Form1_Load(object sender, System.EventArgs e) { }

private void pictureBox1_Click(object sender, System.EventArgs e) { }

/// <summary> /// 应用程序的主入口点。 /// </summary> public class ReadClass { const int SizeBuff=1024; public static void Main() { ReadClass rc=new ReadClass(); rc.Run(); } private void Run() { string path=@"f:\157590516.jpg"; PictureBox1.Image=Image.FromFile(path); } } } }

搜索更多相关主题的帖子: 新建文件夹 命名空间 public 
2005-04-16 14:04
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
你在窗体里加了pictureBox了吗

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-16 14:08
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
PictureBox1 你把P改成p就好了
2005-04-16 18:12
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
另外,你在新建的类(ReadClass)里面是用不到窗框类(Form1)定义的控件的。
2005-04-16 18:16
chenggan
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2005-4-14
收藏
得分:0 
那请问具体应该怎样改呢?

2005-04-16 18:42
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我都把问题的关键告诉你了,还要问?

你把运行的东西放在同一个类里面就行了嘛!
2005-04-16 18:46
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO;

namespace WindowsApplication3 { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.Windows.Forms.PictureBox pictureBox1; private System.ComponentModel.Container components=null;

public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TOD 在 InitializeComponent 调用后添加任何构造函数代码 // }

/// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }

#region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(0, 8); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(288, 256); this.pictureBox1.TabIndex = 0; this.pictureBox1.TabStop = false; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.pictureBox1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion

/// <summary> /// 应用程序的主入口点。 /// </summary>

const int SizeBuff=1024; public static void Main() { Application.Run(new Form1()); } private void Run() { string path=@"f:\157590516.jpg"; pictureBox1.Image = Image.FromFile(path); } } }

2005-04-16 18:49
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
你有点象我gf,我都已经暗示得很白了,她还一定要问到我全部说出来为止。
2005-04-16 18:51
Knocker
Rank: 8Rank: 8
等 级:贵宾
威 望:47
帖 子:10454
专家分:603
注 册:2004-6-1
收藏
得分:0 
咦,这个.....楼上的不是失恋了吗?怎又冒出个gf???

九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。     -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。   -毛泽东
2005-04-16 18:56
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
我哪有失恋。
2005-04-16 19:51
快速回复:求救!!
数据加载中...
 
   



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

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