问题描述
DimWithEventsssAscls1'ss,事件通知我们数据改变DimccAsNewclsH'连接器对象'按这个按钮,修改cls1(ss)的属性值PrivateSubCommand1_Click()ss.mVal=TimeEndSub'初始连接器cc,初始cls1,事件分发对象ssPrivateSubForm_Load()Setss=cc.GetClsEndSub'接受到数据改变事件PrivateSubss_ValChange(vDataAsString)Form1.Caption=ss.mValEndSub这是vb6代码,引用了vb6写的activexexe类型控件,麻烦各位大侠帮忙转换为c#,主要withevents搞不定
解决方案
解决方案二:
DimWithEventsssAscls1-->cls1ss;
解决方案三:
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingtest;namespaceWindowsFormsApplication5{publicpartialclassForm1:Form{clsHcc=newclsH();cls1ss;publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){ss=(cls1)cc.GetCls;}privatevoidbutton1_Click(objectsender,EventArgse){ss.mVal=DateTime.Now.ToString();}privatevoidss_ValChange(stringvData){Text=ss.mVal;}}}我改为这样,不过ss_ValChange不响应
解决方案四:
ss_ValChange,你并没有调用阿
解决方案五:
在vb下是有被调用的,这是那个activeexe控件里的代码PrivatemvarmValAsString'属性变量PublicEventValChange(vDataAsString)'通知事件PublicPropertyLetmVal(ByValvDataAsString)mvarmVal=vDataRaiseEventValChange(vData)EndPropertyPublicPropertyGetmVal()AsStringmVal=mvarmValEndProperty
解决方案六:
ss里有ss.ValChange这个事件,是__cls1_ValChangeEventHandler类型,怎么把ss.ValChange与privatevoidss_ValChange(stringvData)这两个关联起来。附上:publicdelegatevoid__cls1_ValChangeEventHandler(refstringvData);namespacetest{[ComVisible(false)][TypeLibType(16)]publicinterface__cls1_Event{event__cls1_ValChangeEventHandlerValChange;}}
解决方案七:
我只会写到ss.ValChange+=new__cls1_ValChangeEventHandler()里面就不知怎写了