如何在C#Windows应用程序中获取网格列值? [英] How to get column value of grid in C# Windows application?

查看:87
本文介绍了如何在C#Windows应用程序中获取网格列值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#Windows应用程序中获取网格的列值?

How to get column value of grid in C# Windows application?

当我点击单元格时,应该获取列值。

When I clicked on the cell, at that time it should get column values.

private void gridAgentDetails_Click(object sender, EventArgs e)
{
    for (int i = 0; i < this.gridAgentDetails.CurrentRowIndex; i++)
    {
        string str = gridAgentDetails.Text;
    }

}


推荐答案

使用 DataGridView.CurrentCell.Value

String result = this.gridviewAgentDetails.CurrentCell.Value.ToString();






DataGridView.CurrentCell属性获取当前活动的单元格。


DataGridView.CurrentCell Property gets the currently active cell.

DataGridViewCell.Value属性获取与此单元格关联的值。

DataGridViewCell.Value Property gets the value associated with this cell.

这篇关于如何在C#Windows应用程序中获取网格列值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆