“类型”;“记录”;未在自定义类vb.net中定义

“类型”;“记录”;未在自定义类vb.net中定义,vb.net,winforms,combobox,visual-studio-2019,.net-4.7.2,Vb.net,Winforms,Combobox,Visual Studio 2019,.net 4.7.2,我按照下面的思路创建多行组合框。我目前正在使用Visual Studio 2019,该线程来自2013年 我复制的代码: Public Class MultiLineComboBox : Inherits ComboBox Public Sub New() ' Call the base class. MyBase.New() ' Typing a value into this combobox won't make sense, so m

我按照下面的思路创建多行组合框。我目前正在使用Visual Studio 2019,该线程来自2013年

我复制的代码:

    Public Class MultiLineComboBox : Inherits ComboBox
   Public Sub New()
      ' Call the base class.
      MyBase.New()

      ' Typing a value into this combobox won't make sense, so make it impossible.
      Me.DropDownStyle = ComboBoxStyle.DropDownList

      ' Set the height of each item to be twice its normal value
      ' (because we have two lines instead of one).
      Me.ItemHeight *= 2
   End Sub

   Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
      ' Call the base class.
      MyBase.OnDrawItem(e)

      ' Fill the background.
      e.DrawBackground()

      ' Extract the Record object corresponding to the combobox item to be drawn.
      If (e.Index >= 0) Then
         Dim record As Record = DirectCast(Me.Items(e.Index), Record)

         ' Format the item's caption string.
         Dim caption As String = String.Format("ID: {0}{1}Name: {2}", record.UniqueID.ToString(), Environment.NewLine, record.Name)

         ' And then draw that string, left-aligned and vertically centered.
         TextRenderer.DrawText(e.Graphics, caption, e.Font, e.Bounds, e.ForeColor, TextFormatFlags.Left Or TextFormatFlags.VerticalCenter)
      End If

      ' Finally, draw the focus rectangle.
      e.DrawFocusRectangle()
   End Sub
End Class
我创建了一个名为multilecomboBox的类,完全按照指令操作,它说“没有定义类型‘Record’”。我一直在搜索类型“Record”或DirectCast(例如)的答案,但到目前为止,它们都没有帮到我


我的声誉目前请阅读全部答案。
记录
类在此声明;您也需要它,并且希望更改代码以匹配组合框的字段。

该问题的答案中有大量链接,您还没有告诉我们您使用的是哪一个链接。似乎应该是您自己创建了
记录
类。它显然不是标准的.NET类型,所以你认为它应该来自哪里?@jmcilhinney我很抱歉粘贴了错误的链接。这是正确的答案:明白了。我没有阅读答案中提到的OOP部分