DataGridCell.GetHashCode 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得可加入 Hashtable 的雜湊值。
public:
override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer
傳回
在 DataGridCell 中,唯一識別 Hashtable 的數字。
範例
下列範例會將 控制項中 System.Windows.Forms.DataGrid 所選儲存格的雜湊值新增至 Hashtable 。
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