DataObject.GetFormats Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Retourne une liste de tous les formats dans utilisant les données stockées dans ce DataObject format ou peuvent être convertis en.
Surcharges
| Nom | Description |
|---|---|
| GetFormats() |
Retourne une liste de tous les formats dans utilisant les données stockées dans ce DataObject format ou peuvent être convertis en. |
| GetFormats(Boolean) |
Retourne une liste de tous les formats DataObject dans utilisant ou peut être converti en, à l’aide d’un paramètre de conversion automatique pour déterminer s’il faut récupérer uniquement les formats de données natifs ou tous les formats vers utilisant les données. |
GetFormats()
Retourne une liste de tous les formats dans utilisant les données stockées dans ce DataObject format ou peuvent être convertis en.
public:
virtual cli::array <System::String ^> ^ GetFormats();
public virtual string[] GetFormats();
abstract member GetFormats : unit -> string[]
override this.GetFormats : unit -> string[]
Public Overridable Function GetFormats () As String()
Retours
Tableau de type Stringcontenant une liste de tous les formats pris en charge par les données stockées dans cet objet.
Implémente
Exemples
L’exemple de code suivant interroge les DataObject formats associés à ses données, ainsi que les formats auxquels les données peuvent être converties. La liste obtenue s’affiche dans une zone de texte. Ce code nécessite la textBox1 création.
private:
void GetAllFormats()
{
// Creates a new data object using a string and the text format.
DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"Another string" );
// Gets all the data formats and data conversion formats in the DataObject.
array<String^>^ arrayOfFormats = myDataObject->GetFormats();
// Prints the results.
textBox1->Text = "The format(s) associated with the data are: \n";
for ( int i = 0; i < arrayOfFormats->Length; i++ )
{
textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
}
}
private void GetAllFormats() {
// Creates a new data object using a string and the text format.
DataObject myDataObject = new DataObject(DataFormats.Text, "Another string");
// Gets all the data formats and data conversion formats in the DataObject.
String[] arrayOfFormats = myDataObject.GetFormats();
// Prints the results.
textBox1.Text = "The format(s) associated with the data are: " + '\n';
for(int i=0; i<arrayOfFormats.Length; i++)
textBox1.Text += arrayOfFormats[i] + '\n';
}
Private Sub GetAllFormats()
' Creates a new data object using a string and the text format.
Dim myDataObject As New DataObject(DataFormats.Text, "Another string")
' Gets all the data formats and data conversion formats in the DataObject.
Dim arrayOfFormats As String() = myDataObject.GetFormats()
' Prints the results.
textBox1.Text = "The format(s) associated with the data are: " & ControlChars.Cr
Dim i As Integer
For i = 0 To arrayOfFormats.Length - 1
textBox1.Text += arrayOfFormats(i) & ControlChars.Cr
Next i
End Sub
Remarques
Appelez cette méthode pour obtenir les formats de données pris en charge avant d’appeler GetData. Consultez DataFormats les formats prédéfinis.
Note
Les données peuvent être converties dans un autre format s’il a été stocké en spécifiant que cette conversion est autorisée et si le format demandé est compatible avec le format stocké. Par exemple, les données stockées en tant qu’Unicode peuvent être converties en texte.
Voir aussi
S’applique à
GetFormats(Boolean)
Retourne une liste de tous les formats DataObject dans utilisant ou peut être converti en, à l’aide d’un paramètre de conversion automatique pour déterminer s’il faut récupérer uniquement les formats de données natifs ou tous les formats vers utilisant les données.
public:
virtual cli::array <System::String ^> ^ GetFormats(bool autoConvert);
public virtual string[] GetFormats(bool autoConvert);
abstract member GetFormats : bool -> string[]
override this.GetFormats : bool -> string[]
Public Overridable Function GetFormats (autoConvert As Boolean) As String()
Paramètres
- autoConvert
- Boolean
true pour récupérer tous les formats auxquels les données stockées sont DataObject associées, ou peuvent être convertis en ; false pour récupérer uniquement les formats de données natifs.
Retours
Tableau de type Stringcontenant une liste de tous les formats pris en charge par les données stockées dans cet objet.
Implémente
Exemples
L’exemple de code suivant interroge les DataObject formats associés à ses données. La première requête spécifie le autoConvert paramètre en tant que false, de sorte que seul le format natif des données est retourné. La deuxième requête spécifie le autoConvert paramètre en tant que true, de sorte que la liste des formats inclut les formats auxquels les données peuvent être converties.
Ce code nécessite la textBox1 création.
private:
void GetAllFormats2()
{
// Creates a new data object using a string and the text format.
DataObject^ myDataObject = gcnew DataObject( DataFormats::Text,"Another string" );
// Gets the original data formats in the DataObject.
array<String^>^ arrayOfFormats = myDataObject->GetFormats( false );
// Prints the results.
textBox1->Text = "The format(s) associated with the data are: \n";
for ( int i = 0; i < arrayOfFormats->Length; i++ )
{
textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
}
// Gets the all data formats and data conversion formats for the DataObject.
arrayOfFormats = myDataObject->GetFormats( true );
// Prints the results.
textBox1->Text = String::Concat( textBox1->Text , "The data formats and conversion ",
"format(s) associated with the data are: \n" );
for ( int i = 0; i < arrayOfFormats->Length; i++ )
{
textBox1->Text = String::Concat( textBox1->Text, arrayOfFormats[ i ], "\n" );
}
}
private void GetAllFormats2() {
// Creates a new data object using a string and the text format.
DataObject myDataObject = new DataObject(DataFormats.Text, "Another string");
// Gets the original data formats in the DataObject.
String[] arrayOfFormats = myDataObject.GetFormats(false);
// Prints the results.
textBox1.Text = "The format(s) associated with the data are: " + '\n';
for(int i=0; i<arrayOfFormats.Length; i++)
textBox1.Text += arrayOfFormats[i] + '\n';
// Gets the all data formats and data conversion formats for the DataObject.
arrayOfFormats = myDataObject.GetFormats(true);
// Prints the results.
textBox1.Text += "The data formats and conversion format(s) associated with " +
"the data are: " + '\n';
for(int i=0; i<arrayOfFormats.Length; i++)
textBox1.Text += arrayOfFormats[i] + '\n';
}
Private Sub GetAllFormats2()
' Creates a new data object using a string and the text format.
Dim myDataObject As New DataObject(DataFormats.Text, "Another string")
' Gets the original data formats in the DataObject.
Dim arrayOfFormats As String() = myDataObject.GetFormats(False)
' Prints the results.
textBox1.Text = "The format(s) associated with the data are: " & ControlChars.Cr
Dim i As Integer
For i = 0 To arrayOfFormats.Length - 1
textBox1.Text += arrayOfFormats(i) + ControlChars.Cr
Next i
' Gets the all data formats and data conversion formats for the DataObject.
arrayOfFormats = myDataObject.GetFormats(True)
' Prints the results.
textBox1.Text += "The data formats and conversion format(s) associated with " & _
"the data are: " & ControlChars.Cr
For i = 0 To arrayOfFormats.Length - 1
textBox1.Text += arrayOfFormats(i) + ControlChars.Cr
Next i
End Sub
Remarques
Appelez cette méthode pour obtenir les formats de données pris en charge avant d’appeler GetData. Consultez DataFormats les formats prédéfinis.
Note
Les données peuvent être converties dans un autre format s’il a été stocké en spécifiant que cette conversion est autorisée et si le format demandé est compatible avec le format stocké. Par exemple, les données stockées en tant qu’Unicode peuvent être converties en texte.