将ImageCombo从VB6转换为Vb.Net显示简单的非可编辑文本框

时间:2018-01-02 17:14:56

标签: vb.net vb6

我在Vb6中为ImageCombo控件编写了以下代码。

Begin MSComctlLib.ImageCombo dImageCombo 
      Height          =   330
      Index           =   0
      Left            =   120
      TabIndex        =   10
      Top             =   3480
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   582
      _Version        =   393216
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Text            =   "ImageCombo1"
   End

然后我有一个RenderCombo函数如下。它遍历每一行函数,并为ImageCombo中的ItemList获取正确的值,但不显示任何内容。它只是显示为不可编辑的文本视图。

Private Sub RenderCombo(a_dbmgr As ObjectDBManager, _
        ByRef a_X As Integer, ByRef a_Y As Integer, _
        bnode As DataSetNode, fldname As String, _
        MaxPixHeight As Integer, ColMaxWidth As Integer, _
        hLevels As Integer, YStart As Integer, gHeight As Integer, _
        padding As Integer, gInframe As Boolean, a_tooltip As String)
    Dim tstr As String
    Dim ltmp As ComboItem
    Dim lseldata As String
    Dim loldcolwidth As Integer

    Load dImageCombo(nCombos + 1)
    nCombos = nCombos + 1

    tstr = bnode.GetLeafString("WIDTH")
    If tstr <> "" Then
        dImageCombo(nCombos).Width = SafeCLng(tstr)
    End If



            dImageCombo(nCombos).Visible = True
            dImageCombo(nCombos).Left = a_X
            dImageCombo(nCombos).Top = a_Y
            lseldata = bnode.GetLeafString("SELTABLENAV") & "+" & _
                bnode.GetLeafString("SELMATCHFIELD") & "+" & _
                bnode.GetLeafString("SELMATCHNAV") & "+" & _
                bnode.GetLeafString("SELLABELNAME") & "+" & _
                bnode.GetLeafString("SELNOBLANK") & "+" & _
                bnode.GetLeafString("SELVALCAPS") & "+"

            dImageCombo(nCombos).Tag = fldname & "+" & lseldata 


            mMakeComboList a_dbmgr, bnode, nCombos, lseldata


            SetNextXY a_X, a_Y, dImageCombo(nCombos).Width, dImageCombo(nCombos).Height, _
                MaxPixHeight, gHeight, hLevels, YStart, ColMaxWidth, loldcolwidth, "COMBO", gInframe
            If gInframe Then

                dFrame(nFrames).Width = mBumpWidth(dFrame(nFrames).Width, dImageCombo(nCombos).Left + loldcolwidth + padding, "COMBO")
                Set dImageCombo(nCombos).Container = dFrame(nFrames)
            End If
            dImageCombo(nCombos).ToolTipText = a_tooltip

End Sub

迁移后我在VB.Net中获得的代码如下:

Private Sub RenderCombo(ByRef a_dbmgr As ObjectDBManager, ByRef a_X As Short, ByRef a_Y As Short, ByRef bnode As DataSetNode, ByRef fldname As String, ByRef MaxPixHeight As Short, ByRef ColMaxWidth As Short, ByRef hLevels As Short, ByRef YStart As Short, ByRef gHeight As Short, ByRef padding As Short, ByRef gInframe As Boolean, ByRef a_tooltip As String)
        Dim tstr As String = "" 
        Dim ltmp As MSComctlLib.ComboItem
        Dim lseldata As String = "" 
        Dim loldcolwidth As Short

        dImageCombo.Load(nCombos + 1)
        nCombos = nCombos + 1

        tstr = bnode.GetLeafString("WIDTH")
        If tstr <> "" Then
            dImageCombo(nCombos).Width = SafeCLng(tstr)
        End If


            dImageCombo(nCombos).Visible = True
            dImageCombo(nCombos).Left = a_X
            dImageCombo(nCombos).Top = a_Y
            lseldata = bnode.GetLeafString("SELTABLENAV") & "+" & bnode.GetLeafString("SELMATCHFIELD") & "+" & bnode.GetLeafString("SELMATCHNAV") & "+" & bnode.GetLeafString("SELLABELNAME") & "+" & bnode.GetLeafString("SELNOBLANK") & "+" & bnode.GetLeafString("SELVALCAPS") & "+"

            dImageCombo(nCombos).Tag = fldname & "+" & lseldata 


            mMakeComboList(a_dbmgr, bnode, nCombos, lseldata)

            SetNextXY(a_X, a_Y, dImageCombo(nCombos).Width, dImageCombo(nCombos).Height, MaxPixHeight, gHeight, hLevels, YStart, ColMaxWidth, loldcolwidth, "COMBO", gInframe)
            If gInframe Then

                dFrame(nFrames).Width = mBumpWidth(dFrame(nFrames).Width, dImageCombo(nCombos).Left + loldcolwidth + padding, "COMBO")
                dImageCombo(nCombos).Parent = dFrame(nFrames)
            End If
            ToolTip1.SetToolTip(dImageCombo(nCombos), a_tooltip)

    End Sub

迁移后的Designer代码:

Friend WithEvents dImageCombo As AxImageComboArray
Friend WithEvents _dImageCombo_0 As AxMSComctlLib.AxImageCombo
Me._dImageCombo_0 = New AxMSComctlLib.AxImageCombo
Me.dImageCombo = New AxImageComboArray(Me.components)
   CType(Me._dImageCombo_0, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dImageCombo, System.ComponentModel.ISupportInitialize).BeginInit()

        Me.dImageCombo.SetIndex(Me._dImageCombo_0, CType(0, Short))
        Me._dImageCombo_0.Location = New System.Drawing.Point(8, 232)
        Me._dImageCombo_0.Name = "_dImageCombo_0"
        Me._dImageCombo_0.OcxState = CType(resources.GetObject("_dImageCombo_0.OcxState"), System.Windows.Forms.AxHost.State)
        Me._dImageCombo_0.Size = New System.Drawing.Size(121, 22)
        Me._dImageCombo_0.TabIndex = 10
        Me._dImageCombo_0.Visible = False
Me.Controls.Add(Me._dImageCombo_0)
CType(Me._dImageCombo_0, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.dImageCombo, System.ComponentModel.ISupportInitialize).EndInit()

Here is the screenshot of ImageCombo that display as a simple TextBox in Vb.Net.

任何帮助都将不胜感激。

0 个答案:

没有答案