This documentation is archived and is not being maintained.

DataGridCell.ToString Method

Gets the row number and column number of the cell.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

Return Value

A string containing the row number and column number.

Example

[Visual Basic, C#, C++] The following example returns the row number of the System.Windows.Forms.DataGrid control's CurrentCell using the DataGridCell object's ToString method.

[Visual Basic] 
Public Sub DataGrid1_MouseUp(ByVal sender As Object,ByVal e As System.Windows.Forms.MouseEventArgs)
   Dim myGrid As DataGrid = CType(sender, DataGrid)
   Dim myCell As DataGridCell = myGrid.CurrentCell
   Console.WriteLine(myCell.ToString)
End Sub


[C#] 
private void Grid_MouseUp
(object sender, System.Windows.Forms.MouseEventArgs e)
{
   DataGrid dg = (DataGrid)sender;
   DataGridCell myCell = dg.CurrentCell;
   Console.WriteLine(myCell.ToString());
}


[C++] 
private:
void Grid_MouseUp(Object* sender, System::Windows::Forms::MouseEventArgs* /*e*/)
{
   DataGrid* dg = dynamic_cast<DataGrid*>(sender);
   DataGridCell myCell = dg->CurrentCell;
   Console::WriteLine( myCell.ToString() );
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataGridCell Structure | DataGridCell Members | System.Windows.Forms Namespace | ColumnNumber | CurrentCell | DataGrid | RowNumber

Show: