如何在一个form中使用另一个form?

realsong 2003-09-12 06:09:53
这里的form是windows 窗体(.NET)

如何在一个form中使用另一个form?例如:现有两个form,Form1和Form2,如何在Form1.h里面的一个函数里面将Form2显示出来?谢谢!
...全文
145 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xf_david921 2003-09-16
  • 打赏
  • 举报
回复
>_<
_七爷_ 2003-09-16
  • 打赏
  • 举报
回复
不要忘了引用那个对话框的头文件哦#inclue ....
realsong 2003-09-15
  • 打赏
  • 举报
回复
sarcophile(食肉动物)
这样也不行呀:(
返回错误:
e:\My Documents\Visual Studio Projects\test\test\Form1.h(12): error C2871: “Form2” : 具有该名称的命名空间不存在
wolfpzp 2003-09-15
  • 打赏
  • 举报
回复
帮你UP
ArLi2003 2003-09-13
  • 打赏
  • 举报
回复
Form2 * f2 = new Form2();
f2 -> Show();
realsong 2003-09-13
  • 打赏
  • 举报
回复
up
sarcophile 2003-09-13
  • 打赏
  • 举报
回复
是你忘了using namespace form2
realsong 2003-09-12
  • 打赏
  • 举报
回复
在c#里面这样做是可以的,可是在vc.net里面却不行呀!
返回一对错误:
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1632): error C2065: “Form2” : 未声明的标识符
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1632): error C2146: 语法错误 : 缺少“;”(在标识符“frm”的前面)
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1632): error C2065: “frm” : 未声明的标识符
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1632): error C2061: 语法错误 : 标识符“Form2”
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1633): error C2228: “.Show”的左侧必须有类/结构/联合类型
e:\My Documents\Visual Studio Projects\a\b\Form1.h(1633): error C3861: “frm”: 即使使用参数相关的查找,也未找到标识符
timmy3310 2003-09-12
  • 打赏
  • 举报
回复
void showForm2()
{
Form2 frm = new Form2();
frm.Show();
}

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧