IDataObject.GetFormats Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un elenco di tutti i formati in cui i dati archiviati in questa istanza sono associati o possono essere convertiti.
Overload
| Nome | Descrizione |
|---|---|
| GetFormats() |
Restituisce un elenco di tutti i formati in cui i dati archiviati in questa istanza sono associati o possono essere convertiti. |
| GetFormats(Boolean) |
Ottiene un elenco di tutti i formati a cui i dati archiviati in questa istanza sono associati o possono essere convertiti utilizzando un valore booleano per determinare se recuperare tutti i formati che i dati possono essere convertiti in o solo in formati di dati nativi. |
GetFormats()
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
Restituisce un elenco di tutti i formati in cui i dati archiviati in questa istanza sono associati o possono essere convertiti.
public:
cli::array <System::String ^> ^ GetFormats();
public string[] GetFormats();
abstract member GetFormats : unit -> string[]
Public Function GetFormats () As String()
Valori restituiti
Matrice dei nomi che rappresenta un elenco di tutti i formati supportati dai dati archiviati in questo oggetto.
Esempio
In questo esempio viene usata la DataObject classe , che implementa IDataObject, per illustrare l'uso del GetFormats metodo . Prima di tutto, crea un oggetto dati (myDataObject) usando una stringa e il Text formato . Recupera quindi tutti i formati di dati e i formati di conversione dei dati nell'oggetto dati e visualizza l'elenco risultante in una finestra di messaggio. In questo esempio si presuppone che sia stato creato un Form oggetto denominato Form1.
private:
void GetFormats1()
{
// Creates a data object using a string and the Text format.
DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"My text string" );
// Gets all the data formats and data conversion formats in the data object.
array<String^>^allFormats = myDataObject->GetFormats();
// Creates the string that contains the formats.
String^ theResult = "The format(s) associated with the data are: \n";
for ( int i = 0; i < allFormats->Length; i++ )
theResult = theResult + allFormats[ i ] + "\n";
// Displays the result in a message box.
MessageBox::Show( theResult );
}
private void GetFormats1()
{
// Creates a data object using a string and the Text format.
DataObject myDataObject = new DataObject(DataFormats.Text, "My text string");
// Gets all the data formats and data conversion formats in the data object.
String[] allFormats = myDataObject.GetFormats();
// Creates the string that contains the formats.
string theResult = "The format(s) associated with the data are: " + '\n';
for(int i = 0; i < allFormats.Length; i++)
theResult += allFormats[i] + '\n';
// Displays the result in a message box.
MessageBox.Show(theResult);
}
Private Sub GetFormats1()
' Creates a data object using a string and the Text format.
Dim myDataObject As New DataObject(DataFormats.Text, "My text string")
' Gets all the data formats and data conversion formats in the data object.
Dim allFormats As [String]() = myDataObject.GetFormats()
' Creates the string that contains the formats.
Dim theResult As String = "The format(s) associated with the data are: " & _
vbCr
Dim i As Integer
For i = 0 To allFormats.Length - 1
theResult += allFormats(i) + vbCr
Next i
' Displays the result in a message box.
MessageBox.Show(theResult)
End Sub
Commenti
Chiamare questo metodo per ottenere i formati di dati supportati prima di chiamare il GetData metodo . Vedere la DataFormats classe per i formati predefiniti.
Note
I dati possono essere convertiti in un altro formato se sono stati archiviati specificando che la conversione è consentita e se il formato richiesto è compatibile con il formato archiviato. Ad esempio, i dati archiviati come Unicode possono essere convertiti in testo.
Per un'implementazione di questo metodo, vedere DataObject.GetFormats.
Vedi anche
Si applica a
GetFormats(Boolean)
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
- Origine:
- IDataObject.cs
Ottiene un elenco di tutti i formati a cui i dati archiviati in questa istanza sono associati o possono essere convertiti utilizzando un valore booleano per determinare se recuperare tutti i formati che i dati possono essere convertiti in o solo in formati di dati nativi.
public:
cli::array <System::String ^> ^ GetFormats(bool autoConvert);
public string[] GetFormats(bool autoConvert);
abstract member GetFormats : bool -> string[]
Public Function GetFormats (autoConvert As Boolean) As String()
Parametri
- autoConvert
- Boolean
true per recuperare tutti i formati in cui i dati archiviati in questa istanza sono associati o possono essere convertiti; false per recuperare solo i formati di dati nativi.
Valori restituiti
Matrice dei nomi che rappresenta un elenco di tutti i formati supportati dai dati archiviati in questo oggetto.
Esempio
In questo esempio viene usata la DataObject classe , che implementa IDataObject, per illustrare l'uso del GetFormats metodo . Prima di tutto, crea un oggetto dati (myDataObject) usando una stringa e il UnicodeText formato . Esegue quindi due query per ottenere i formati associati ai dati. Nella prima query imposta il autoConvert parametro su false : in questo caso, viene restituito solo il formato nativo dei dati. Nella seconda query imposta il autoConvert parametro su true, in modo che ottenga l'elenco dei formati, inclusi i formati in cui è possibile convertire i dati. In ogni caso, l'elenco risultante viene visualizzato in una finestra di messaggio. In questo esempio si presuppone che sia stato creato un Form oggetto denominato Form1.
private:
void GetFormats2()
{
// Creates a new data object using a string and the UnicodeText format.
DataObject^ myDataObject = gcnew DataObject( DataFormats::UnicodeText,"My text string" );
// Gets the original data formats in the data object by setting the automatic
// conversion parameter to false.
array<String^>^myFormatsArray = myDataObject->GetFormats( false );
// Stores the results in a string.
String^ theResult = "The original format associated with the data is:\n";
for ( int i = 0; i < myFormatsArray->Length; i++ )
theResult = theResult + myFormatsArray[ i ] + "\n";
// Gets all data formats and data conversion formats for the data object.
myFormatsArray = myDataObject->GetFormats( true );
// Stores the results in the string.
theResult = theResult + "\nThe data format(s) and conversion format(s) associated with the data are:\n";
for ( int i = 0; i < myFormatsArray->Length; i++ )
theResult = theResult + myFormatsArray[ i ] + "\n";
// Displays the results.
MessageBox::Show( theResult );
}
private void GetFormats2()
{
// Creates a new data object using a string and the UnicodeText format.
DataObject myDataObject = new DataObject(DataFormats.UnicodeText, "My text string");
// Gets the original data formats in the data object by setting the automatic
// conversion parameter to false.
String[] myFormatsArray = myDataObject.GetFormats(false);
// Stores the results in a string.
string theResult = "The original format associated with the data is:\n";
for(int i = 0; i < myFormatsArray.Length; i++)
theResult += myFormatsArray[i] + '\n';
// Gets all data formats and data conversion formats for the data object.
myFormatsArray = myDataObject.GetFormats(true);
// Stores the results in the string.
theResult += "\nThe data format(s) and conversion format(s) associated with " +
"the data are:\n";
for(int i = 0; i < myFormatsArray.Length; i++)
theResult += myFormatsArray[i] + '\n';
// Displays the results.
MessageBox.Show(theResult);
}
Private Sub GetFormats2()
' Creates a new data object using a string and the UnicodeText format.
Dim myDataObject As New DataObject(DataFormats.UnicodeText, "My text string")
' Gets the original data formats in the data object by setting the automatic
' conversion parameter to false.
Dim myFormatsArray As [String]() = myDataObject.GetFormats(False)
' Stores the results in a string.
Dim theResult As String = "The original format associated with the data is:" & vbCr
Dim i As Integer
For i = 0 To myFormatsArray.Length - 1
theResult += myFormatsArray(i) + vbCr
Next i
' Gets all data formats and data conversion formats for the data object.
myFormatsArray = myDataObject.GetFormats(True)
' Stores the results in the string.
theResult += vbCr + "The data format(s) and conversion format(s) associated with " & _
"the data are:" & vbCr
For i = 0 To myFormatsArray.Length - 1
theResult += myFormatsArray(i) + vbCr
Next i
' Displays the results.
MessageBox.Show(theResult)
End Sub
Commenti
Chiamare questo metodo per ottenere i formati di dati supportati prima di chiamare il GetData metodo . Vedere la DataFormats classe per i formati predefiniti.
Note
I dati possono essere convertiti in un altro formato se sono stati archiviati specificando che la conversione è consentita e se il formato richiesto è compatibile con il formato archiviato. Ad esempio, i dati archiviati come Unicode possono essere convertiti in testo.
Per un'implementazione di questo metodo, vedere DataObject.GetFormats.