DataGridCell.GetHashCode 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.
Ottiene un valore hash che è possibile aggiungere a un oggetto Hashtable.
public:
override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer
Restituisce
Numero che identifica in modo univoco l'oggetto DataGridCell in un oggetto Hashtable.
Esempio
Nell'esempio seguente viene aggiunto il valore hash della cella selezionata in un System.Windows.Forms.DataGrid controllo a un Hashtableoggetto .
private:
Hashtable^ myHashTable;
public:
Form1()
{
myHashTable = gcnew Hashtable;
}
private:
void Grid_MouseUp( Object^ sender, System::Windows::Forms::MouseEventArgs^ /*e*/ )
{
DataGrid^ dg = dynamic_cast<DataGrid^>(sender);
DataGridCell myCell = dg->CurrentCell;
String^ tempkey = myCell.ToString();
Console::WriteLine( "Temp {0}", tempkey );
if ( myHashTable->Contains( tempkey ) )
{
return;
}
myHashTable->Add( tempkey, myCell.GetHashCode() );
Console::WriteLine( "Hashcode: {0}", myCell.GetHashCode() );
}
private Hashtable myHashTable = new Hashtable();
private void Grid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid dg = (DataGrid)sender;
DataGridCell myCell = dg.CurrentCell;
string tempkey = myCell.ToString();
Console.WriteLine("Temp " + tempkey);
if(myHashTable.Contains(tempkey)){return;}
myHashTable.Add(tempkey, myCell.GetHashCode());
Console.WriteLine("Hashcode: " + myCell.GetHashCode().ToString());
}
Private myHashTable As New Hashtable()
Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim dg As DataGrid = CType(sender, DataGrid)
Dim myCell As DataGridCell = dg.CurrentCell
Dim tempkey As String = myCell.ToString
Console.WriteLine("Temp " & tempkey)
If myHashTable.Contains(tempkey) Then Exit Sub
myHashTable.Add(tempkey, myCell.GetHashCode)
Console.WriteLine("Hashcode: " & myCell.GetHashCode.ToString)
End Sub