rt,不适用MDI方式。
解决方案 »
- C# 开发 Excel 外接程序 加载错误
- 关于assembly
- 如果我有表1 ,表2,表3,表4。怎么才能用一个方法把他们都保存修改过了呢,怎么做成一个方法,该方法是返回什么类型的?
- 挑战高手!!如何对添加,删除,修改 dns 里的 a type记录;急急急急急!!!!在线等待,分不够再给!!
- 怎样才能使winform产生的exe 文件在其他电脑中可以运行
- Com+的一下“订阅”的问题。
- C# 执行 二进制流
- 轻轻地我来了,就不会轻易地走,从此与大家同甘共苦 C# !
- C# 全局钩子获取键值问题
- VS03按装问题?急!急!
- 关于传递方式
- c# 用adox创建access数据库,打不开,提示不可识别
parentform.controls.add(subform);
subform.show();
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsApplication92
{
public partial class Form1 : Form
{ [DllImport("user32.dll")]
public static extern int SetParent(int hWndChild, int hWndNewParent); public Form1()
{
InitializeComponent(); Form F = new Form();
F.Show();
SetParent(F.Handle.ToInt32(), this.Handle.ToInt32());
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.TopLevel = false;
this.Controls.Add(frm);
frm.Show();
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;namespace WindowsFormsApplication56
{
public partial class Form1 : Form
{ [DllImport("user32.dll")]
public static extern int SetParent(int hWndChild, int hWndNewParent); Form F = null; public Form1()
{
InitializeComponent(); F = new Form();
F.Show();
SetParent(F.Handle.ToInt32(), this.Handle.ToInt32()); F.LocationChanged += new EventHandler(F_LocationChanged);
this.Resize += new EventHandler(Form1_Resize); this.Scroll += new ScrollEventHandler(Form1_Scroll);
} void Form1_Resize(object sender, EventArgs e)
{
SetScroll(F);
} void F_LocationChanged(object sender, EventArgs e)
{
SetScroll(F);
} void SetScroll(Form F)
{
Point P = this.PointToClient(F.Location); this.HorizontalScroll.Maximum = (P.X + F.Width) / this.Width * 10;
this.HorizontalScroll.Value = 0;
this.VerticalScroll.Maximum = (P.Y + F.Height) / this.Height * 10;
this.VerticalScroll.Value = 0; int VerticalScrollWidth = this.VerticalScroll.Maximum > 0 ? 20 : 0;
int HorizontalScrollWidth = this.HorizontalScroll.Maximum > 0 ? 20 : 0; this.HorizontalScroll.Visible = (P.X + F.Width + VerticalScrollWidth) > this.Width;
this.VerticalScroll.Visible = (P.Y + F.Height + HorizontalScrollWidth) > this.Height;
} void Form1_Scroll(object sender, ScrollEventArgs e)
{
// .....
}
}
}
this.AutoScroll = true;