共用方式為


DataGridCell.ToString 方法

定義

取得儲存格的資料列編號和資料行編號。

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

傳回

含有資料列編號和資料行編號的字串。

範例

下列範例會使用 物件的 方法傳回 控制項 CurrentCell 的資料列編號 System.Windows.Forms.DataGridToStringDataGridCell

private:
   void Grid_MouseUp(
      Object^ sender, System::Windows::Forms::MouseEventArgs^ /*e*/ )
   {
      DataGrid^ dg = (DataGrid^)(sender);
      DataGridCell myCell = dg->CurrentCell;
      Console::WriteLine( myCell.ToString() );
   }
private void Grid_MouseUp
(object sender, System.Windows.Forms.MouseEventArgs e)
{
   DataGrid dg = (DataGrid)sender;
   DataGridCell myCell = dg.CurrentCell;
   Console.WriteLine(myCell.ToString());
}
Private 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

適用於

另請參閱