主窗体程序: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApp20 {
调用OCX控件的步骤:1.在系统中注册该ocx控件,命令:regsvr32.exe 控件位置(加 /u 参数是取消注册)2.在.net的工具箱中添加该控件,拖到form中去就可以了. 不用工具箱的话,自己手工添加,需要注意一个问题,就是要用Aximp.exe来包装一下ocx控件的类,然后再程序中引用生成的dll就可以了.aximp [options]{file.dll | file.ocx}The following command generates MediaPlayer.dll and A
解决办法是Form类中定义一个静态的ActiveX对象,在formload中将界面上的ActiveX对象赋值给新定义的对象,类中访问该静态对象即可. public static AxClientDriver_NTLib.AxClientDriverCtrl com = new AxClientDriver_NTLib.AxClientDriverCtrl(); private void Form1_Load(object sender, EventArgs e) { com = this.axC
如果自定义类需要调用窗体控件,首先需要将窗体控件的可见级别(Modifiers)设为public.如下图所示: 然后在Form1类下定义静态变量form1,并初始化. class Form1: Form { //在Form1类下定义静态变量 public static Form1 form1; public Form1() { InitializeComponent(); form1 = this; } } 然后在自定类中调用 public class Myclass { public void