当前位置: 首页>>代码示例>>C#>>正文


C# DataRow.Item属性代码示例

本文整理汇总了C#中System.Data.DataRow.Item属性的典型用法代码示例。如果您正苦于以下问题:C# DataRow.Item属性的具体用法?C# DataRow.Item怎么用?C# DataRow.Item使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Data.DataRow的用法示例。


在下文中一共展示了DataRow.Item属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DataGrid1_Click

private void DataGrid1_Click(object sender, 
       System.EventArgs e)
   {
       // Get the DataTable the grid is bound to.
       DataGrid thisGrid = (DataGrid) sender;
       DataTable table = (DataTable) thisGrid.DataSource;
       DataRow currentRow = 
           table.Rows[thisGrid.CurrentCell.RowNumber];

       // Get the value of the column 1 in the DataTable.
       Console.WriteLine(currentRow[1]);
       // You can also use the name of the column:
       // Console.WriteLine(currentRow["FirstName"])
   }

   private void SetDataRowValue(DataGrid grid, object newValue)
   {
       // Set the value of the last column in the last row of a DataGrid.
       DataTable table;
       table = (DataTable) grid.DataSource;
       DataRow row;

       // Get last row
       row = (DataRow)table.Rows[table.Rows.Count-1];

       // Set value of last column
       row[table.Columns.Count-1] = newValue;
   }
开发者ID:.NET开发者,项目名称:System.Data,代码行数:28,代码来源:DataRow.Item

示例2: DataGrid1_Click

private void DataGrid1_Click(
       object sender, System.EventArgs e)
   {
       // Get the DataTable the grid is bound to.
       DataGrid thisGrid = (DataGrid) sender;
       DataTable table = (DataTable) thisGrid.DataSource;
       DataRow currentRow = 
           table.Rows[thisGrid.CurrentCell.RowNumber];

       // Get the value of the column 1 in the DataTable.
       Console.WriteLine(currentRow["FirstName"]);
       // You can also use the index:
       // Console.WriteLine(currentRow[1]);
   }

   private void SetDataRowValue(
       DataGrid grid, object newValue)
   {
       // Set the value of the first column in 
       // the last row of a DataGrid.
       DataTable table = (DataTable) grid.DataSource;
       DataRow row = table.Rows[table.Rows.Count-1];
       row["FirstName"] = newValue;
   }
开发者ID:.NET开发者,项目名称:System.Data,代码行数:24,代码来源:DataRow.Item

示例3: DataGrid1_Click

private void DataGrid1_Click(object sender, 
    System.EventArgs e) 
{
    DataTable dataGridTable = 
        (DataTable)DataGrid1.DataSource;

    // Set the current row using the RowNumber 
    // property of the CurrentCell.
    DataRow currentRow = dataGridTable.Rows[DataGrid1.CurrentCell.RowNumber];
    DataColumn column = dataGridTable.Columns[1];

    // Get the value of the column 1 in the DataTable.
    Console.WriteLine(currentRow[column, DataRowVersion.Current]);
}
开发者ID:.NET开发者,项目名称:System.Data,代码行数:14,代码来源:DataRow.Item

示例4: DataGrid1_Click

private void DataGrid1_Click(object sender, System.EventArgs e)
{
    // Set the current row using the RowNumber 
    // property of the CurrentCell.
    DataRow currentRow =
        ((DataTable)(DataGrid1.DataSource)).
        Rows[DataGrid1.CurrentCell.RowNumber];

    // Print the current value of the column named "FirstName."
    Console.WriteLine(currentRow["FirstName", 
        DataRowVersion.Current]);
}
开发者ID:.NET开发者,项目名称:System.Data,代码行数:12,代码来源:DataRow.Item


注:本文中的System.Data.DataRow.Item属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。