首先需要将用户控件定义为public的,从工具箱拖动到窗口的,转到Form的InitializeComponent();方法,将其改为public.
namespace JointOfficial.Forms
{
partial class DemoForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.clientFindMain1 = new JointOfficial.UserControls.ClientFindMain();
this.SuspendLayout();
//
// clientFindMain1
//
this.clientFindMain1.Dock = System.Windows.Forms.DockStyle.Fill;
this.clientFindMain1.Location = new System.Drawing.Point(0, 0);
this.clientFindMain1.Name = "clientFindMain1";
this.clientFindMain1.Size = new System.Drawing.Size(284, 262);
this.clientFindMain1.TabIndex = 0;
//
// DemoForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Controls.Add(this.clientFindMain1);
this.Name = "DemoForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DemoForm";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.DemoForm_Load);
this.ResumeLayout(false);
}
#endregion
public UserControls.ClientFindMain clientFindMain1;//用户控件在此....
}
}
调用的时候:
(Application.OpenForms["DemoForm"] as Forms.DemoForm).clientFindMain1.GoSelect("http://www.myluoluo.com");
[warning]需要注意次窗口是否已经被实例化[/warning]
博客做的8错。卤煮不会是女主吧,哈哈
男生。。。。。- – 不要在怀疑了。。。
看这博客~那也是一只小受了~^O^
你真聪明。。。。这都能猜出来。。。。
我也是在校学生,而且,C# Big Fan,哈哈,发Q号到我Email~我加你
原来是学生啊。加油啊。
毕业了