DataGridCell.GetHashCode Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a hash value that can be added to a Hashtable.
public:
override int GetHashCode();
public override int GetHashCode ();
override this.GetHashCode : unit -> int
Public Overrides Function GetHashCode () As Integer
Returns
A number that uniquely identifies the DataGridCell in a Hashtable.
Examples
The following example adds the hash value of the selected cell in a System.Windows.Forms.DataGrid control to a 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
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET