| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 983 人关注过本帖
标题:子窗体与主窗体的问题
只看楼主 加入收藏
MichaelChan
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-2-3
收藏
 问题点数:0 回复次数:3 
子窗体与主窗体的问题
C#入门经典里面的,我按照上面的抄的,还是有错误,不知道咋的.请问该如何改啊,谢谢!!!
我用的是VS2005.
这是一个建立MDI的例子:
//这是子窗体的源代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace P355
{
public partial class frmChild : Form
{
public frmChild()
{
InitializeComponent();
//Set the parent of the form to the container
this.MdiParent = Parent; //这里提示"Error 14 Cannot implicitly convert type 'System.Windows.Forms.Control' to 'System.Windows.Forms.Form'. An explicit conversion exists (are you missing a cast?)"
}

private void frmChild_Load(object sender, EventArgs e)
{

}
}
}

//这是主窗口代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace P355
{
public partial class mdiBasic : Form
{
public mdiBasic()
{
InitializeComponent();
//Create a new instance of the child form
mdiBasic.frmChild child = new mdiBasic.frmChild(this); //这里提示"Error 13 The type name 'frmChild' does not exist in the type 'P355.mdiBasic'
//Show the form
child.Show();
}

private void frmContainer_Load(object sender, EventArgs e)
{

}
}
}
搜索更多相关主题的帖子: 子窗体 using System 源代码 
2006-02-03 12:48
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
你会看英文吗?

我意思是:你看得懂出错提示的意思吗?

[此贴子已经被作者于2006-2-4 8:53:21编辑过]

2006-02-04 08:50
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
那段代码在2003是运行正常的,可能是2005的规定严格了,

也可能是2005的规定的变量名字变了,


个人建议:请不要照书抄代码来运行,那是死板的,无味的。
2006-02-04 08:52
live41
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:67
帖 子:12442
专家分:0
注 册:2004-7-22
收藏
得分:0 
你可以随便抄几段,但请不要完全照抄来运行,因为完全照抄基本上无意义。
2006-02-04 08:53
快速回复:子窗体与主窗体的问题
数据加载中...
 
   



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

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