110,534
社区成员
发帖
与我相关
我的任务
分享
[C#]
// Tabel样式取得
DataGridTableStyle ts;
ts = DataGrid1.TableStyles["DataTable1"];
//被选择的列取得
int cn = DataGrid1.CurrentCell.ColumnNumber;
// DataGridTextBoxColumn取得
DataGridTextBoxColumn cs =
(DataGridTextBoxColumn) ts.GridColumnStyles[cn];
// TextBox取得
TextBox tb = cs.TextBox;
//被选择的字符串取得
Console.WriteLine(tb.SelectedText);
foreach (DataRow dr in dataGridView1.SelectedRows)
{
string col1 = dr[0].ToString(); // 这是每行第一列的值
string col2 = dr[1].ToString(); // 这是每行第二列的值
string col3 = dr[2].ToString(); // 这是每行第三列的值
}