Implicit conversion warning and

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bamapookie

    #1

    Implicit conversion warning and

    I have a subroutine that I modified from code I found in this forum
    (thanks). I'll include it below for public use, and to illustrate my
    problem. The sub accepts a ListBox control and an enumeration. It
    creates a datasource from the enum and sets the ListBox to use the
    datasource. If I pass a ComboBox (which is derived from ListBox) into
    the sub, I get a warning about the implicit conversion back to a
    ComboBox when the Sub exits. Is there a way to avoid this warning?
    Here is the Sub:

    Private Shared Sub LoadEnumIntoLC( ByVal typedata As Type, _
    ByRef lc As ListControl)
    Dim dt As New DataTable
    dt.Columns.Add( "Display", GetType(String) )
    dt.Columns.Add( "Value", typedata)

    For Each obj As Object In [Enum].GetValues(type data)
    Dim row As DataRow = dt.NewRow
    row("Display") = obj.ToString()
    row("Value") = obj
    dt.Rows.Add(row )
    Next

    lc.DataSource = dt
    lc.DisplayMembe r = "Display"
    lc.ValueMember = "Value"
    End Sub

  • bamapookie

    #2
    Re: Implicit conversion warning and

    Note: I meant to refer to a ListControl, not a ListBox. Both ListBox
    and ComboBox are derived from ListControl.

    Comment

    • Jan Hyde

      #3
      Re: Implicit conversion warning and

      "bamapookie " <bamapookie@gma il.com>'s wild thoughts were
      released on 20 May 2005 08:19:01 -0700 bearing the following
      fruit:
      [color=blue]
      >Note: I meant to refer to a ListControl, not a ListBox. Both ListBox
      >and ComboBox are derived from ListControl.[/color]

      And how are you calling that routine?



      Jan Hyde (VB MVP)

      --
      You feel stuck with your debt if you can't budge it. (Karen Mascew)

      [Abolish the TV Licence - http://www.tvlicensing.biz/]

      Comment

      • bamapookie

        #4
        Re: Implicit conversion warning and

        Friend WithEvents cbWindowStyle As System.Windows. Forms.ComboBox
        ' ProcessWindowSt yle is the Enum System.Diagnost ics.ProcessWind owStyle

        LoadEnumIntoLC( GetType(Process WindowStyle), cbWindowStyle)

        Comment

        Working...