将C#代码移植到vb.net - eventhandler

时间:2016-10-23 12:33:54

标签: vb.net

我正在尝试从C#移植以下代码,但不知道!它将如何转换为事件处理程序

C#

Select+=new EventHandler(OnSelectEvent);
if (!isMainMenuItem)
    {
        OwnerDraw=true;
        MeasureItem+=new MeasureItemEventHandler(OnMeasureItem);
        DrawItem+=new DrawItemEventHandler(OnDrawItem);
    }

移植代码:

  [Select] += New EventHandler(AddressOf OnSelectEvent)

    If Not isMainMenuItem Then
        OwnerDraw = True
        ' AddHandler Menuitem.select, new measuritemeventhandler(addressof onmeasureitem)
        MeasureItem += New MeasureItemEventHandler(AddressOf OnMeasureItem)
        DrawItem += New DrawItemEventHandler(AddressOf OnDrawItem)
    End If

1 个答案:

答案 0 :(得分:0)

+ =标记不能在VB.net中使用,您必须使用AddHandler命令。 它的语法不一样。

AddHandler MeasureItem, AddressOf OnMeasureItem

阅读此Topic 1 Topic 2 它可能对你有帮助

找到相同的问题Here