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

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
 
C

Cor

Hi Johannes,

Can you try this?

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

Cor
 
T

Teemu Keiski

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
 

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