Drag & Drop in Excel

D

David Thielen

Hi;

When we provide a IDataObject to Excel for a Drag & Drop operation,
when the user actually drops the text in Excel, we need to handle that
ourselves as Excel replaces the text in the cell and we want to add
it. Plus for one object, we need to write to multiple cells.

The problem is, Excel calls IDataObject.GetData() twice - once
immediately and then again when dropping the text. Is it safe to
assume that Excel will always call GetData() exactly twice? Or is
there some other way to know when Excel is calling it to drop as
opposed to doing so, I assume, as a way to verify that the data format
it wants is available.

And does this rul hold for Excel 2000/2002/2003/2007?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

Jialiang Ge [MSFT]

Hello Dave,

When you drag and drop a custom data object to Office, Office check whether
the supported data format (e.g. Text, Object Descriptor, Filedrop, Rtf) is
present by calling GetDataPresent. If the format is present in the object,
it calls GetData for the format. Therefore, to avoid multiple calls of
GetData, you may use this solution:

(suppose the only supported format of our object is DataFormats.Text)

public bool GetDataPresent(string format, bool autoConvert)
{
if (format == DataFormats.Text.ToString())
return true;
else return false;
}

public object GetData(string format, bool autoConvert)
{
//if (format == DataFormats.Text.ToString())
return Clipboard.GetData(DataFormats.Text.ToString());
//else
// return null;
}

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

It appears that Excel calls it the first time to get the number of
rows and columns in the data to be dropped so it can draw the drop
location.

thanks - dave


Hello Dave,

When you drag and drop a custom data object to Office, Office check whether
the supported data format (e.g. Text, Object Descriptor, Filedrop, Rtf) is
present by calling GetDataPresent. If the format is present in the object,
it calls GetData for the format. Therefore, to avoid multiple calls of
GetData, you may use this solution:

(suppose the only supported format of our object is DataFormats.Text)

public bool GetDataPresent(string format, bool autoConvert)
{
if (format == DataFormats.Text.ToString())
return true;
else return false;
}

public object GetData(string format, bool autoConvert)
{
//if (format == DataFormats.Text.ToString())
return Clipboard.GetData(DataFormats.Text.ToString());
//else
// return null;
}

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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