本文整理汇总了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;
}
示例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;
}
示例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]);
}
示例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]);
}