新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
概述C#調用Active組件
在編碼中不可否認調用Active會給編程帶來很大便利,雖然微軟不太只持C#調用Active組件。本實例是一個簡單Web 頁面調用Active組件的例子,實現(xiàn)把數(shù)據(jù)傳入并顯示在active組件里的控件中。

為大石橋等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及大石橋網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為成都網(wǎng)站設計、成都做網(wǎng)站、大石橋網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
實例代碼如下:
C#調用Active組件
本程序中:建立類庫添加組件類后托放:label 、 button 、groupBox各一個,需要注意的是在生成.dll之前一定要在類庫的AssemblyInfo.cs中加入引用using System.Security;和屬性[assembly : AllowPartiallyTrustedCallers()],這是為了給控件賦予足夠的權限使它能在頁面上顯示。
- usingSystem;
- usingSystem.ComponentModel;
- usingSystem.Collections;
- usingSystem.Diagnostics;
- usingSystem.Windows.Forms;
- namespaceActiveXDotNet
- {
- /**////
- ///AbeenControl的摘要說明。
- ///
- publicclassAbeenControl:System.Windows.Forms.UserControl
- {
- privateSystem.Windows.Forms.Labellabel1;
- privateSystem.Windows.Forms.Buttonbutton1;
- privateSystem.Windows.Forms.GroupBoxgroupBox1;
- /**////
- ///必需的設計器變量。
- ///
- privateSystem.ComponentModel.Containercomponents=null;
- publicstringLabelText
- {
- get
- {
- returnthis.label1.Text.ToString();
- }
- set
- {
- this.label1.Text=value;
- }
- }
- publicAbeenControl(System.ComponentModel.IContainercontainer)
- {
- /**////
- ///Windows.Forms類撰寫設計器支持所必需的
- ///
- this.label1.Text="test";
- container.Add(this);
- InitializeComponent();
- //
- //TODO:在InitializeComponent調用后添加任何構造函數(shù)代碼
- //
- }
- publicAbeenControl()
- {
- /**////
- ///Windows.Forms類撰寫設計器支持所必需的
- ///
- InitializeComponent();
- //
- //TODO:在InitializeComponent調用后添加任何構造函數(shù)代碼
- //
- }
- /**////
- ///清理所有正在使用的資源。
- ///
- protectedoverridevoidDispose(booldisposing)
- {
- if(disposing)
- {
- if(components!=null)
- {
- components.Dispose();
- }
- }
- base.Dispose(disposing);
- }
以上介紹C#調用Active組件。
【編輯推薦】
- 如何用C#和ADO.NET訪問
- 淺析C# Switch語句
- C#驗證輸入方法詳解
- 簡單介紹C# 匿名方法
- C# FileSystemWatcher對象
文章題目:概述C#調用Active組件
鏈接分享:http://www.5511xx.com/article/coshhce.html


咨詢
建站咨詢
