Option Strict On disallows implicit conversions from 'System.Object' to '1-dimensional array of Syst

  • Thread starter Thread starter Johannes Peeters
  • Start date Start date
J

Johannes Peeters

Hello,

I'm using the example from
http://msdn.microsoft.com/library/d.../en-us/dv_vstechart/html/vbtchimpdragdrop.asp
, Dragging Between Lists

However, with option strict set to on, i get the following
message:Option Strict On disallows implicit conversions from
'System.Object' to '1-dimensional array of
System.Windows.Forms.ListViewItem'.

The error is about this line:
Dim myItems() As ListViewItem =
e.Data.GetData("System.Windows.Forms.ListViewItem()")

Does anyone know how i should avoid this? I just can't find it, and i
need to have option stricted turned on.

Thanks,
Johannes Peeters
 
Hi Johannes,

Can you try this?

DirectCast(e.Data.GetData("System.Windows.Forms.ListViewItem()"),
ListViewItem())

Cor
 
If you can't have implicit conversion, it means you need to do it
explicitly. It means you need to cast to the target type.

Dim myItems() As ListViewItem
=CType(e.Data.GetData("System.Windows.Forms.ListViewItem()"),ListViewItem())

Does the method return an array of ListViewItem?

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



Hello,

I'm using the example from
http://msdn.microsoft.com/library/d.../en-us/dv_vstechart/html/vbtchimpdragdrop.asp
, Dragging Between Lists

However, with option strict set to on, i get the following
message:Option Strict On disallows implicit conversions from
'System.Object' to '1-dimensional array of
System.Windows.Forms.ListViewItem'.

The error is about this line:
Dim myItems() As ListViewItem =
e.Data.GetData("System.Windows.Forms.ListViewItem()")

Does anyone know how i should avoid this? I just can't find it, and i
need to have option stricted turned on.

Thanks,
Johannes Peeters
 
Back
Top