这是另外一种方式,可以查找特定的行private void FindInMultiPKey(DataTable myTable){ DataRow foundRow; // Create an array for the key values to find. object[]findTheseVals = new object[3]; // Set the values of the keys to find. findTheseVals[0] = "John"; findTheseVals[1] = "Smith"; findTheseVals[2] = "5 Main St."; foundRow = myTable.Rows.Find(findTheseVals); // Display column 1 of the found row. if(foundRow != null) Console.WriteLine(foundRow[1]); }
2.DataSet.Tables[0].Rows
3.DataSet.Tables[0].Rows[0][0]
好像求不出来。
BindingManagerBase.Position访问
for (j=0;j<=i-1;j++ )
{
MessageBox.Show ( theDataSet.Tables[tableName].Columns[j].ColumnName);
MessageBox.Show ( theDataSet.Tables[tableName].Rows[0][j].ToString ());
}
94
1.DataSet.Tables[0].Columns.Count,DataSet.Tables[0].Columns[0].ColumnName
2.DataSet.Tables[0].Rows
3.DataSet.Tables[0].Rows[0][0]
可以得到指定行的数据DataGrid.CurrentRowIndex 属性 可以得到当前行的行号而一般,dataset 总是和 datagrid 绑定的,可以两者结合,达到你的目的
DataRow foundRow;
// Create an array for the key values to find.
object[]findTheseVals = new object[3];
// Set the values of the keys to find.
findTheseVals[0] = "John";
findTheseVals[1] = "Smith";
findTheseVals[2] = "5 Main St.";
foundRow = myTable.Rows.Find(findTheseVals);
// Display column 1 of the found row.
if(foundRow != null)
Console.WriteLine(foundRow[1]);
}
private void dataGrid1_Click(object sender, System.EventArgs e)
{
MessageBox.Show ( common.dbindex.ToString() );
}