专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »DotNet » active组件:在C#中调用Active 组件 »正文

active组件:在C#中调用Active 组件

来源: 发布时间:星期三, 2008年9月10日 浏览:95次 评论:0

本实例是一个简单Web页面调用Active组件的例子,实现把数据传入并显示在active组件里的控件中。
  实例代码如下:
1、建立Active组件(这里用.net c#创建)
(本程序中:建立类库添加组件类后托放:label、button、groupBox各一个)
   需要注意的是在生成.dll之前一定要在类库的AssemblyInfo.cs中加入引用usingSystem.Security;和属性[assembly:AllowPartiallyTrustedCallers()],这是为了给控件赋予足够的权限使它能在页面上显示。

usingSystem;
usingSystem.ComponentModel;
usingSystem.Collections;
usingSystem.Diagnostics;
usingSystem.Windows.Forms;

namespaceActiveXDotNet
{
/**////<summary>
///AbeenControl的摘要说明。
///</summary>
publicclassAbeenControl:System.Windows.Forms.UserControl
{
privateSystem.Windows.Forms.Labellabel1;
privateSystem.Windows.Forms.Buttonbutton1;
privateSystem.Windows.Forms.GroupBoxgroupBox1;
/**////<summary>
///必需的设计器变量。
///</summary>
privateSystem.ComponentModel.Containercomponents=null;

publicstringLabelText
{
get
{
returnthis.label1.Text.ToString();
}
set
{
this.label1.Text=value;
} [Page]
}

publicAbeenControl(System.ComponentModel.IContainercontainer)
{
/**////
///Windows.Forms类撰写设计器支持所必需的
///
this.label1.Text=\"test\";
container.Add(this);
InitializeComponent();

//
//TODO:在InitializeComponent调用后添加任何构造函数代码
//
}

publicAbeenControl()
{
/**////
///Windows.Forms类撰写设计器支持所必需的
///
InitializeComponent();


//
//TODO:在InitializeComponent调用后添加任何构造函数代码
//
}

/**////<summary>
///清理所有正在使用的资源。
///</summary>
protectedoverridevoidDispose(booldisposing)

0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: