次の方法で共有


DataGridCell.ToString メソッド

セルの行番号と列番号を取得します。

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

戻り値

行番号と列番号を格納している文字列。

使用例

[Visual Basic, C#, C++] DataGridCell オブジェクトの ToString メソッドを使用して、 System.Windows.Forms.DataGrid コントロールの CurrentCell の行番号を返す例を次に示します。

 
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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

DataGridCell 構造体 | DataGridCell メンバ | System.Windows.Forms 名前空間 | ColumnNumber | CurrentCell | DataGrid | RowNumber