private void initializecomponent ( )
{
this.groupbox1 = new system.windows.forms.groupbox ( ) ;
this.txtusertext = new system.windows.forms.textbox ( ) ;
this.label1 = new system.windows.forms.label ( ) ;
this.groupbox1.suspendlayout ( ) ;
this.suspendlayout ( ) ;
this.groupbox1.controls.add ( this.txtusertext ) ;
this.groupbox1.controls.add ( this.label1 ) ;
this.groupbox1.location = new system.drawing.point ( 8 , 8 ) ;
this.groupbox1.name = "groupbox1" ;
this.groupbox1.size = new system.drawing.size ( 272 , 56 ) ;
this.groupbox1.tabindex = 0 ;
this.groupbox1.tabstop = false ;
this.groupbox1.text = "visual studio .net创建的active x组件" ;
this.txtusertext.enabled = false ;
this.txtusertext.location = new system.drawing.point ( 84 , 20 ) ;
this.txtusertext.name = "txtusertext" ;
this.txtusertext.size = new system.drawing.size ( 180 , 21 ) ;
this.txtusertext.tabindex = 1 ;
this.txtusertext.text = "" ;
this.label1.location = new system.drawing.point ( 8 , 24 ) ;
this.label1.name = "label1" ;
this.label1.size = new system.drawing.size ( 66 , 16 ) ;
this.label1.tabindex = 0 ;
this.label1.text = "输入信息:" ;
this.controls.add ( this.groupbox1 ) ;
this.name = "mycontrol" ;
this.size = new system.drawing.size ( 288 , 72 ) ;
this.groupbox1.resumelayout ( false ) ;
this.resumelayout ( false ) ;
}
public interface axmycontrol
{
string usertext { set ; get ; }
}
private string mstr_usertext ;
public string usertext
{
get { return mstr_usertext ; }
set
{
mstr_usertext = value ;
//修改组件的数值
txtusertext.text = value ;
}
}
using system ;
using system.collections ;
using system.componentmodel ;
using system.drawing ;
using system.data ;
using system.windows.forms ;
namespace activexdotnet
{
public interface axmycontrol
{
string usertext { set ; get ; }
}
/// <summary>
/// mycontrol 的摘要说明。
/// </summary>
public class mycontrol : system.windows.forms.usercontrol , axmycontrol
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private system.componentmodel.container components = null ;
private system.windows.forms.groupbox groupbox1 ;
private system.windows.forms.label label1 ;
private system.windows.forms.textbox txtusertext ;
private string mstr_usertext ;
public string usertext
{
get { return mstr_usertext ; }
set
{
mstr_usertext = value ;
//修改组件的数值
txtusertext.text = value ;
}
}
public mycontrol ( )
{
// 该调用是 windows.forms 窗体设计器所必需的。
initializecomponent ( ) ;
// todo: 在 initializecomponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void dispose ( bool disposing )
{
if ( disposing )
{
if ( components != null )
{
components.dispose ( ) ;
}
}
base.dispose ( disposing ) ;
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void initializecomponent ( )
{
this.groupbox1 = new system.windows.forms.groupbox ( ) ;
this.txtusertext = new system.windows.forms.textbox ( ) ;
this.label1 = new system.windows.forms.label ( ) ;
this.groupbox1.suspendlayout ( ) ;
this.suspendlayout ( ) ;
this.groupbox1.controls.add ( this.txtusertext ) ;
this.groupbox1.controls.add ( this.label1 ) ;
this.groupbox1.location = new system.drawing.point ( 8 , 8 ) ;
this.groupbox1.name = "groupbox1" ;
this.groupbox1.size = new system.drawing.size ( 272 , 56 ) ;
this.groupbox1.tabindex = 0 ;
this.groupbox1.tabstop = false ;
this.groupbox1.text = "visual c#创建的active x组件" ;
this.txtusertext.enabled = false ;
this.txtusertext.location = new system.drawing.point ( 84 , 20 ) ;
this.txtusertext.name = "txtusertext" ;
this.txtusertext.size = new system.drawing.size ( 180 , 21 ) ;
this.txtusertext.tabindex = 1 ;
this.txtusertext.text = "" ;
this.label1.location = new system.drawing.point ( 8 , 24 ) ;
this.label1.name = "label1" ;
this.label1.size = new system.drawing.size ( 66 , 16 ) ;
this.label1.tabindex = 0 ;
this.label1.text = "输入信息:" ;
this.controls.add ( this.groupbox1 ) ;
this.name = "mycontrol" ;
this.size = new system.drawing.size ( 288 , 72 ) ;
this.groupbox1.resumelayout ( false ) ;
this.resumelayout ( false ) ;
}
#endregion
}
}
<html>
<body color = white>
<hr>
<font face = arial size = 1>
<object id = "mycontrol1" name = "mycontrol1" classid = "activexdotnet.dll#activexdotnet.mycontrol" width = 288 height = 72 >
</object>
</font>
<form name = "frm" id = "frm" >
<input type = "text" name = "txt" value = "请输入数据:" ><input type = button value = "确定" onclick = "doscript ( ) ; ">
</form>
<hr>
</body>
<script language = "javascript">
function doscript ( )
{
mycontrol1.usertext = frm.txt.value ;
}
</script>
</html>
新闻热点
疑难解答