Live Chat Icon For mobile
Live Chat Icon

How do I create a DataObject?

Platform: WPF| Category: Drag and Drop

A DataObject can be created in three different overloads of the DataObject constructor.

  • DataObject (object) – In this case, appropriate DataFormat is assigned to the DataObject based on the type of data stored in the object. By default, auto-conversion option is set to ’true’.
  • [C#]
    
    string mystring = 'Drag and Drop String Object';
    DataObject dataobject = new DataObject(mystring);
    
  • DataObject (DataFormat, object) – In this case, DataFormat is mentioned when the DataObject is created.
  • [C#]
    
    string mystring = 'Drag and Drop String Object';
    DataObject dataobject = new DataObject(DataFormats.UnicodeText,mystring);
    
  • DataObject (DataFormat, Object, auto-conversion) – In this case, DataFormat, Object and Auto-Conversion Boolean value are mentioned when the DataObject is created.
  • [C#]
    
    string mystring = 'Drag and Drop String Object';
    DataObject dataobject = new DataObject(DataFormats.UnicodeText,mystring,false);
    

    Share with

    Related FAQs

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.