[VB.NET]怎么把form1插入form2中(急!!!在线等)

VB.NET源码-156个实用实例哦…… <script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
怎么把form1插入form2中(急!!!在线等)
怎么把form1插入form2中?? form1中有panel,在form2中怎么调用form1中的panel及panel上的控件???
__________________________________________________________________________
能继承的啊。
__________________________________________________________________________
怎么实现的??
帮忙给个代码!!谢谢
__________________________________________________________________________
晕倒
你在创建好第一个FORM1时,存盘,最好再运行一下。然后在IDE右边的资源管理器上右击,选择添加WINDOWS窗体,添加上继承的窗体,这个时候要选择你的FORM1就行了。
__________________________________________________________________________
添加上继承的窗体是哪一项啊??
我这怎么没有啊??
我的是2005!form版的
__________________________________________________________________________
在右边你的项目的列表的项目名称那里右键> 添加新..> 继承的窗体
然后就能添加一个跟form1一摸一样的窗体
---------------------------------------------------------------------------------------------
如果你要在form2直接调用form1的控件,就在form2里面写代码form1.控件名字
比如我在form1有textbox1,form2要控制它的文本,则
form1.textbox1.text = "控制完毕 "
__________________________________________________________________________
我用的是.net Express Edition版本的!
没有你说的那个选项!
__________________________________________________________________________
怎么用代码实现啊??
__________________________________________________________________________
form1.Controls.Panel.Controls.TextBox1.Text = "控制 ";

尝试一下
__________________________________________________________________________
不行啊!

form2怎么继承form1用代码写??
__________________________________________________________________________
继承窗体Express版本是肯定有的...就在添加新窗体那选择...你平时是怎么添加新窗体的,不要选择第一个...看仔细..肯定有 继承窗体的...就在第一列...
__________________________________________________________________________
这是VB.NET的基本功能,肯定有的。
你选择添加窗体,找那个继承窗体,然后就会出现一个提示框,它里面会让你选择,你选择你的FORM1就行了。
__________________________________________________________________________
Sorry刚才没注意是VB.NET,刚写了一个C#的示例,楼主看看是不是这个意思:

//Form1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
private Panel panel1 = new Panel();
private Button button1 = new Button();
public Form1()
{
InitializeComponent();

this.Controls.Add(panel1);

panel1.Left = 0;

panel1.Controls.Add(button1);

button1.Text = "wbj ";

button1.Click +=new EventHandler(button1_Click);

}

private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();

this.Owner = form2;

form2.Show();

}

public Button OwnerButton
{
get { return button1; }
set { button1 = value; }
}
}

//Form2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form2 : Form
{
private Label label1 = new Label();
public Form2()
{
InitializeComponent();


}

private void Form2_Load(object sender, EventArgs e)
{
this.Controls.Add(label1);

label1.Left = 0;

label1.Text = ((Form1)this.OwnedForms[0]).OwnerButton.Text;
}
}
}
__________________________________________________________________________
Dialog1.vb
Explorer1.vb
MDIParent1.vb
AboutBox1.vb
LoginForm1.vb
SplashScreen1.vb
Class1.vb
Module1.vb
UserControl1.vb
TextFile1.txt

大家帮我看看哪个是????
__________________________________________________________________________
//接上:继承窗体的代码写法:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form3 : Form1
{
public Form3()
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)
{
this.OwnerButton.Text = "Changed ";
}
}
}
__________________________________________________________________________
上边的例子要验证的话,需把Form1中的
private void button1_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();

this.Owner = form2;

form2.Show();

}

改为:
private void button1_Click(object sender, EventArgs e)
{
//Form2 form2 = new Form2();

//this.Owner = form2;

//form2.Show();

Form3 form3 = new Form3();
form3.Show();


}
__________________________________________________________________________
就是最后一列的 继承的窗体。。。名字就像 form1.vb, form2.vb一样的那种...
图标是两个windows 窗体..后面那个淡一点
__________________________________________________________________________
需要那么麻烦吗?
在VB2005里不就几行代码的事情吗?
假设form1里有个panel1,panel1里有个TextBox1
form2里有个Button1

那么form2里的这个按钮的Click代码是:
Form1.Panel1.BackColor = Color.Blue ''改变form1.Panel1的背景颜色
Form1.TextBox1.Text = "Hello! Text "改变form1.TextBox1的文本内容

真不明白各位还在说什么继承之类的做什么用?
__________________________________________________________________________
因为他不仅是要控制..是要完全一样...
__________________________________________________________________________
他说两个form要完全一样了吗?如果是这样,那就是他提问质量不高了。
__________________________________________________________________________
lgx1972() 你真是个饼子,别人都理解对了,就你自己理解错了你在这狡辩什么???
__________________________________________________________________________
=.= " 楼主消失了
__________________________________________________________________________
楼主弄好了么...
__________________________________________________________________________
还没那
__________________________________________________________________________
我在重装.NET2005
__________________________________________________________________________
inherits
__________________________________________________________________________
Mark!
__________________________________________________________________________
直接在form2中插入

form1.show()
form1.focus()

可行??
__________________________________________________________________________
hmilj245216() ( ) 信誉:100 2007-9-5 12:29:47 得分: 0



lgx1972() 你真是个饼子,别人都理解对了,就你自己理解错了你在这狡辩什么???




饼子都是高手。你可知道c++饼子堂。里面都是> 8年的c++元老。
__________________________________________________________________________
饼子都是高手。你可知道c++饼子堂。里面都是> 8年的c++元老。


哈哈,我证实此话有水份,“都是> 8年的c++元老”这是胡扯
__________________________________________________________________________
我以为:
年龄都是> 8年的c++元老
这样理解就是对的啦
__________________________________________________________________________
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值