Table of contents
TOC
折叠目录
展开目录

DataObject 与 Clipboard 之间有何区别?What is the difference between the DataObject and the Clipboard?

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

数据对象和剪贴板都提供将数据从一个位置移动到另一种方法。作为应用程序开发人员,有几个要点需要记住当您使用DataObject或剪贴板:The DataObject and the Clipboard both provide a means to move data from one place to another. As an application developer, there are several important points to remember when you use either a DataObject or the Clipboard:

  • 只要每段数据具有不同的数据格式,可以将多个数据存储DataObject或剪贴板上的一次。如果您将数据存储在正在使用的格式,新数据被保存和旧的数据将被丢弃。You can store more than one piece of data at a time on either a DataObject or the Clipboard as long as each piece of data has a differentdata format. If you store data with a format that is already in use, the new data is saved and the old data is discarded.

  • 图片格式和文本格式,剪贴板支持。DataObject目前支持仅文本格式。The Clipboard supports picture formats and text formats. A DataObject currently supports only text formats.

  • 数据对象在仅存在运行应用程序;剪贴板上存在,只要操作系统运行。这意味着可以将数据放在剪贴板上,并关闭应用程序,而不会丢失数据。不是使用数据对象,则返回 true。如果您关闭数据放入数据对象的应用程序,您将丢失的数据。A DataObject exists only while your application is running; the Clipboard exists as long as the operating system is running. This means you can put data on the Clipboard and close an application without losing the data. The same is not true with the DataObject. If you close the application that put data on a DataObject, you lose the data.

  • DataObject是标准 OLE 对象,而不是剪贴板。这意味着剪贴板可以支持标准的移动操作 (复制、 剪切和粘贴) 但不是拖放操作。如果您希望应用程序支持拖放操作,则必须使用数据对象A DataObject is a standard OLE object, while the Clipboard is not. This means the Clipboard can support standard move operations (copy, cut, and paste) but not drag-and-drop operations. You must use the DataObject if you want your application to support drag-and-drop operations.

提示 使用SetText方法将数据移动到剪贴板或数据对象时,您可以定义您自己的数据格式的名称。这可以帮助区分应用程序移动的文本和用户移动的文本。Tip You can define your own data format names when you use the SetText method to move data to the Clipboard or a DataObject. This can help distinguish between text that your application moves and text that the user moves.

© 2018 Microsoft