DataGridCell::GetHashCode Method ()

 

Gets a hash value that can be added to a Hashtable.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
virtual int GetHashCode() override

Return Value

Type: System::Int32

A number that uniquely identifies the DataGridCell in a Hashtable.

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() );
   }

.NET Framework
Available since 1.1
Return to top
Show: