博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

winfrom程序中dataGridiew控件获取选中单元格相关代码

Posted on 2012-11-05 10:31  JmrBrvae  阅读(231)  评论(0编辑  收藏  举报

前段时间开发遇到了一些问题,在此记录一下。

            //获取选中单元格的值
            dataGridView1.CurrentCell.Value.ToString();
            //获取选中单元格的索引值
            int indexNo = dataGridView1.CurrentCell.ColumnIndex;
            //获取选中单元格的列的表头值
            string headerText=dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText;