Implicit conversion warning and

B

bamapookie

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(typedata)
Dim row As DataRow = dt.NewRow
row("Display") = obj.ToString()
row("Value") = obj
dt.Rows.Add(row)
Next

lc.DataSource = dt
lc.DisplayMember = "Display"
lc.ValueMember = "Value"
End Sub
 
B

bamapookie

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

Jan Hyde

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

And how are you calling that routine?



Jan Hyde (VB MVP)
 
B

bamapookie

Friend WithEvents cbWindowStyle As System.Windows.Forms.ComboBox
' ProcessWindowStyle is the Enum System.Diagnostics.ProcessWindowStyle

LoadEnumIntoLC(GetType(ProcessWindowStyle), cbWindowStyle)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top