您好,我设法找到了我的鼠标突出显示的行。但是我不知道如何访问它的内容。
例如:我突出显示了第 25 行我可以得到它突出显示的第 25 行但是我不知道如何访问其内容并将其全部放在文本框中。有人吗?
最佳答案
您可以使用 value 属性访问单元格的内容,如下所示
// the content of the cell
var x = dataGridView1.Rows[0].Cells[0].Value;
// this gets the content of the first selected cell
dataGridView1.SelectedCells[0].Value;
// you can set the cells the user is able to select using this
dataGridView1.SelectionMode= SelectionMode. //intellisense gives you some options here
完全按照您的要求做这样的事情就足够了
System.Text.StringBuilder t = new System.Text.StringBuilder();
String delimiter = ",";
foreach(DataGridViewCell c in dataGridView1.SelectedRows[0].Cells)
{
t.Append(c.Value);
t.Append(delimiter);
}
textBox1.Text = t.ToString();
关于c# - 访问单元格datagridview Winform C#的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8871423/