请教各位:
我做了个自定义控件并添加个属性,为什么我在属性窗口中修改了这个属性,可是却没能跟其他控件一样自动初始化修改过的控件属性??
我的源码:
这是自定义控件的部分代码.
private SqlConnection conn = new SqlConnection();
/// <summary>
/// 此属性用于保存一个通用的数据库链接串.
/// </summary>
public SqlConnection Conn
{
get
{
return conn;
}
set
{
conn = value;
}
}这是自定义控件在窗体设计器生成代码处的代码:(UC_Login1就是我做的那个自定义控件)
private void InitializeComponent()
{
this.uC_Login1 = new WCL_SACsystem.UC_Login();
this.SuspendLayout();
//
// uC_Login1
//
this.uC_Login1.Location = new System.Drawing.Point(12, 13);
this.uC_Login1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.uC_Login1.Name = "uC_Login1";
this.uC_Login1.Size = new System.Drawing.Size(311, 241);
this.uC_Login1.TabIndex = 0;
//
// main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(587, 449);
this.Controls.Add(this.uC_Login1);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "main";
this.Text = "main";
this.Load += new System.EventHandler(this.main_Load);
this.ResumeLayout(false); }
uC_Login1.conn的属性在手动调整后这里并没有自动的添加.如果是我在窗口打开事件里自己添加一段程序,这个程序就是可用的.
不知道他为什么没有自动添加修改的类属性?
在线等!!!
我做了个自定义控件并添加个属性,为什么我在属性窗口中修改了这个属性,可是却没能跟其他控件一样自动初始化修改过的控件属性??
我的源码:
这是自定义控件的部分代码.
private SqlConnection conn = new SqlConnection();
/// <summary>
/// 此属性用于保存一个通用的数据库链接串.
/// </summary>
public SqlConnection Conn
{
get
{
return conn;
}
set
{
conn = value;
}
}这是自定义控件在窗体设计器生成代码处的代码:(UC_Login1就是我做的那个自定义控件)
private void InitializeComponent()
{
this.uC_Login1 = new WCL_SACsystem.UC_Login();
this.SuspendLayout();
//
// uC_Login1
//
this.uC_Login1.Location = new System.Drawing.Point(12, 13);
this.uC_Login1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.uC_Login1.Name = "uC_Login1";
this.uC_Login1.Size = new System.Drawing.Size(311, 241);
this.uC_Login1.TabIndex = 0;
//
// main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(587, 449);
this.Controls.Add(this.uC_Login1);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "main";
this.Text = "main";
this.Load += new System.EventHandler(this.main_Load);
this.ResumeLayout(false); }
uC_Login1.conn的属性在手动调整后这里并没有自动的添加.如果是我在窗口打开事件里自己添加一段程序,这个程序就是可用的.
不知道他为什么没有自动添加修改的类属性?
在线等!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货